4

Using Google Maps Android v2, how can I snap a route drawn with a polyline or just the points that are getting connected to a street?

I am getting locations from Google Play Services, but accurency is usually around 5-10 meters, so points are not directly on the street, but a bit wrong.

Andreas Ka
  • 839
  • 9
  • 23

3 Answers3

1

One possible way would be to ask Google Directions API for the exact path between two consecutive points returned to you as Location objects.

Example request:

http://maps.googleapis.com/maps/api/directions/json?origin=37,-96&destination=37,-96.1&sensor=false

Remember there is a limit of 2500 request per day per user (IP), so you may also want to limit your LocationClient or LocationManager updates.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
1

You could take a look at this blog post guide I wrote on how to make a call to Google directions API parse the point and present them on Google Map:

Google maps directions using Google Directions API and Polylines

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • yes, probably that's the way to go. However it seems this API is not a part of the Android framework or Google Play Services, so it won't work when the user is offline which is quite a bit of a downsite. – Andreas Ka Jul 03 '13 at 01:29
0

I think what you want is the snapToRoads method provided by Google Roads API. You just need to provide the polyline LatLng points and it will return you a JSON file consist of polyline points that is snap more smoothly to the roads.

https://developers.google.com/maps/documentation/roads/snap

Komgcn
  • 323
  • 2
  • 12