4

I have an OSM Map and I have got updated latitude and longitude as I am moving on the way, after every 10 seconds. I want to draw a route line on the map as the user moves away. i.e. I want to connect all the pairs of lat-lon.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Maddy Sharma
  • 4,870
  • 2
  • 34
  • 40

2 Answers2

5

If you are using Osmdroid to display your OSM map, then what you need is a PathOverlay to which you can add points with its addPoint() method. See my answer to this question OSMDroid PathOverlay

You should be able to adapt your code very easily from this example.

Community
  • 1
  • 1
NickT
  • 23,844
  • 11
  • 78
  • 121
  • Yeah its working... thanks Sir..., Now I am able to draw the path but I have three buttons on my map scree. Pause(to pause path recording),poi(to add pin on a specific location) and start/stop(to start or stop recording).in my onLocationChanged(), I m calling requestUpdate...() and I m giving 10 mtr length and 1 minute time for update location.But I receive lat/lon either i close the App. I also call removeUpdate...() on clicking on pause and stop both.Then why I receive lat/lon continuously. Thanks in advance... – Maddy Sharma Sep 16 '12 at 17:44
2

Here:

private Polyline polyline;
private ArrayList<GeoPoint> pathPoints;

polyline = new Polyline();
polyline.setColor(Helper.getColor(context, R.color.red));
polyline.setWidth(POLYLINE_WIDTH);
mapView.getOverlays().add(polyline);

pathPoints.add(newLatLon);
pathPoints.add(newLatLon1);
pathPoints.add(newLatLon2);
polyline.setPoints(pathPoints);
M. Usman Khan
  • 3,689
  • 1
  • 59
  • 69