Google Maps Android: snap polyline to street

Using Google Maps Android v2, how can I snap a route drawn by a polyline or just points that connect to the street?

I get addresses from Google Play Services, but the accuracy is usually 5-10 meters, so the points are not directly on the street, but a little wrong.

+4
source share
3 answers

You can take a look at this blog guide I wrote about how to call the Google APIs, analyze the point and present it on a Google Map:

Google maps using API and Google Directions policies

+2
source

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

Request example:

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

Remember that there is a limit of 2500 requests per day per user (IP), so you can also restrict LocationClient or LocationManager updates.

+1
source

I think you need the snapToRoads method provided by the Google Roads API. You just need to provide the LatLng polyline points, and it will return you a JSON file consisting of polyline points that will smoothly move along the roads.

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

0
source

Source: https://habr.com/ru/post/1489224/


All Articles