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.
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.
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.