I have an app in which I am continuously tracking user\'s location using Google Plays new service API for Maps. I am updating the location every single second and I am also
Your code for drawing the path looks strange.
Inside the for-loop
you should only add the points to an instance of PolylineOptions
(which you create before entering the for loop).
Then, after the for-loop
you can add the width
, color
etc. to the polylineOptions
object
and finally use that in mGoogleMap.addPolyline()
.
In your coding, you are somehow adding a new polyline
for each point (I am wondering that this draws lines at all, as each "line" consists of one point only.).
You should split your problem into the aspects of data collection and data display.
Therefore take two coordinates you precisely know and draw a straight polyline on google maps. If it's really displayed at the wrong location, GoogleMap has indeed a bug, which BTW I don't believe.
Then print out your coordinates e.g. to LogCat before drawing them and check the coordinates. If they are wrong, it is not a problem of GoogleMaps but of the LocationProvider or of how you use it.
If the coordinates are collected correctly, you may pick them somehow up from LogCat and use them directly in your code to draw a polyline. If then the polyline is displaced, you may again have found a bug in GoogleMap. Then you should paste the coordinates here, so someone can reproduce it. It may be device dependent. I never had a polyline which did not match the map.
This code will work
GoogleMap map;
// ... get a map.
// Add a thin red line from London to New York.
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
.width(5)
.color(Color.RED));