My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 5313: Bug: Polylines drawn incorrectly in certain cases
51 people starred this issue and may be notified of changes. Back to list
Status:  Acknowledged
Owner:  ----


Sign in to add a comment
 
Reported by [email protected], Apr 26, 2013
Certain kinds of polylines are drawn incorrectly in certain zoom levels. The behavior is only visible if you zoom near enough, at higher levels polyline is drawn correctly. Our application uses GPS locations to draw polylines and the drawing issues seem more common when a device has been standing still for a while and draws a lot of jittery lines around it.

Attached some screenshots and a sample Java-file that contains example data and a PolylineBugData.createBuggyPolyline() method which can be used to reproduce the behavior. The data was randomly generated to exhibit the bug because extracting real data which causes the issue would be more difficult. It is probably also possible to remove points from the attached sample data and still retain the buggy behavior. 

The bug is present at the "February 2013" release of Google Maps v2 and shows up at least on these devices:

-Samsung Galaxy S (2.3.3)
-Samsung Galaxy Mini (2.3.4)
-Galaxy Nexus 4 (4.2.1)
-Galaxy Nexus 7 (4.2.2)
-Samung XCover (2.3.6)



*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

device-2013-04-26-142533.png
161 KB   View   Download
device-2013-04-26-142622.png
88.4 KB   View   Download
device-2013-04-26-142650.png
101 KB   View   Download
PolylineBugData.java
16.8 KB   View   Download
Apr 26, 2013
#1 [email protected]
Might be related to Issue 5123
May 27, 2013
#2 [email protected]
I have also come across this bug, also on relatively jittery data recorded while standing still, or walking back and forth in a 1-2m area.

Additional info:
- The artefact (bug) line always appears to leave my drawn route heading due North, East, South or West. Direction can switch based on zoom.
- The artefact only appears when the zoom is pushed to quite high (approx 2 highest) levels, but will then remain for considerable zoom out actions before eventually disappearing again.
- Seen on HTC Desire, Android v2.2
Jul 2, 2013
#4 [email protected]
I have also come across this, I don't think its just when you zoom in, I have found that it happens with different amounts of data and also different zoom levels (about 11 and 8) how ever it can be reproduced by going in to the same position and zoom level, you can also follow line line for quite some time and then it disappears 


working.png
306 KB   View   Download
Screenshot_2013-07-02-21-29-07.png
353 KB   View   Download
Screenshot_2013-07-02-21-29-14.png
411 KB   View   Download
Screenshot_2013-07-02-21-33-06.png
342 KB   View   Download
Screenshot_2013-07-02-21-33-43.png
324 KB   View   Download
Jul 2, 2013
#5 [email protected]
This was on a Samsung Galaxy Nexus running 4.2.2
Jul 5, 2013
#6 [email protected]
I have implemented a filter to skip points closer than 1 metre, and that seems to have eradicated the problem. I haven't adjusted the threshold to see if it works on less. It is extra processing I'd rather not be doing.

Has anyone found any other work arounds?
Jul 5, 2013
#7 [email protected]
Is that what causes it? When there is a abundance of points in one place?
Sep 24, 2013
#8 [email protected]
Is there any resolution for this issue?  I'm having some of the same issues, particularly at screen/projection edges.
Sep 24, 2013
#9 [email protected]
http://stackoverflow.com/questions/17422314/polylines-appearing-on-map-where-they-shouldnt


You have to filter out lines that are too close to each other. 
Jan 26, 2014
#10 [email protected]
I could track it down to a very simple case with only 4 points. (Indeed the last point is not even needed).
See:
http://stackoverflow.com/questions/21361069/cant-draw-an-arrow-using-polyline-in-googlemap-v2
In this case it has nothing to do with points being very near, but just with the fact, that the same segment is drawn once to west and then back to east. And it only happens if the segment goes absolutely straight towards west and east. The same code works, if the segment goes only a bit towards north or south in addition.
Jan 26, 2014
#11 [email protected]
Just wanted to add the example code also here.
Resulting shape should be a kind of arrow, but the horizontal line extends to infinity.

PolylineOptions po = new PolylineOptions();
    LatLng p1 = new LatLng(49.4, 8.45);
    LatLng p2 = new LatLng(49.3, 8.6);
    LatLng p3 = new LatLng(49.3, 8.5);
    LatLng p4 = new LatLng(49.35, 8.6);

    po.add(p1);
    po.add(p2);
    po.add(p3);
    po.add(p2);
    po.add(p4);
    map.addPolyline(po);
Feb 24, 2014
#13 [email protected]
It seems to be when a path crosses back over itself.  For me it happens when a user needs to make a u-turn.  My attempt to work around the issue has lead me to introduce a bit a randomization to the polyline:

  Random rand = new Random();
  foreach (var vertice in path)
  {
    double lat = vertice[0];
    double lng = vertice[1];

    lat = lat + rand.NextDouble() / 10000;
    lng = lng + rand.NextDouble() / 10000;
....

Not perfect, but seems to be working.
Sep 11, 2014
Project Member #14 [email protected]
(No comment was entered for this change.)
Status: Acknowledged
Labels: Internal-17479064
Oct 24, 2014
#15 [email protected]
Stumbled with this issue when requesting small route too GoogleDirectionsApi. Any workaround still? Already like one year past.
Mar 4, 2015
#16 [email protected]
Same here.
I've tried to filter points too close to each other, but the problem still occurs.
The only things that makes sense is that it happens when the polyline makes a u-turn.
Bu I cannot add randomization. I need to put the points exacly where they are.
Mar 4, 2015
#17 [email protected]
A not so beautiful workaround that worked for us: alter the similar coordinates with a value less than you position error tolarence, so that they won't be exactly the same. For us a value like 0.000001 worked fine. So the example in comment #11 would look like:

PolylineOptions po = new PolylineOptions();
    LatLng p1 = new LatLng(49.4, 8.45);
    LatLng p2 = new LatLng(49.300001, 8.600001);
    LatLng p3 = new LatLng(49.3, 8.5);
    LatLng p4 = new LatLng(49.35, 8.6);

    po.add(p1);
    po.add(p2);
    po.add(p3);
    po.add(p2);
    po.add(p4);
    map.addPolyline(po);

This way the lines will look the same on screen, but you won't encounter the problem. Of course, this needs a little extra logic, to determine the points that have the sam e coordinates.
Mar 4, 2015
#18 [email protected]
I'm working on a tablet with xhdpi density screen and I'm discarding from my dataset the points with the same latitude and longitude of the previous one.
The bug occurs when two points making a u-turn (horizontal or vertical) have a distance of 0.000001. 
So the solution suggested in #17 won't work, or at least should consider to add an offset proportional to the screen density.
But keep in mind that, for me, neither the solution of computing the distance from the last point and discard the closest one ( < 1 meter) worked.
I think it's not a problem of distance. In other situations, where there are two points very close but not u-turning, the issue is not occurring. 
May 8, 2015
#19 [email protected]
Is there any solid fix for this bug now?
Jun 22, 2015
Project Member #20 [email protected]
 Issue 8010  has been merged into this issue.
Jun 22, 2015
Project Member #21 [email protected]
 Issue 8166  has been merged into this issue.
Jun 24, 2015
Project Member #22 [email protected]
 Issue 7483  has been merged into this issue.
Nov 17, 2015
#23 [email protected]
Up
Feb 11, 2016
#24 [email protected]
having this same problem on Nexus 6 running 6.0.1
Feb 17, 2016
#26 [email protected]
I managed to reproduce this error for the last 2 years, on several phones.  The smallest way to reproduce this is:

        LatLng p1 = new LatLng(32.084, 34.806);
        LatLng p2 = new LatLng(32.086, 34.806);
        LatLng p3 = new LatLng(32.086, 34.807);

        polyline.add(p1);
        polyline.add(p2);
        polyline.add(p1); // this one messes up
        polyline.add(p3);

        LatLngBounds.Builder bounds = new LatLngBounds.Builder();
        bounds.include(p1).include(p2).include(p3);
        mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 100));

Again, the workaround is to remove some points from my line. In my case the tolerance is 0.001. I am not happy about "not displaying" the correct data (even though I know the points are bellow the GPS accuracy, so ignoring them is not a bad idea anyway).

Mar 24, 2016
#27 [email protected]
Up. Same on Galaxy Google Nexus.
Sign in to add a comment

Powered by Google Project Hosting