ridvan
ridvan

Reputation: 743

route many coordinates in google map android

When I draw a route in google map between two coordinates, I am using below Google API URL it works I can get all data, but now I can draw route between many coordinates how can I do this?

http://maps.googleapis.com/maps/api/directions/xml?origin=41.020381,28.936672&destination=41.023722,28.939016&sensor=false&units=metric&mode=driving

Upvotes: 1

Views: 705

Answers (2)

Greg
Greg

Reputation: 910

You can use waypoints, the documentation can be found here:

Google Maps APIs Waypoints

However, since waypoints only support a maximum of 23 waypoints, you'll need to divide the total number of points by 23 to get the interval you need to leave between points to end up with 23. This will not give you an incredibly accurate route, since you'll be missing many of the recorded points.

We found that an alternate solution was to not use the Google Maps Directions API, instead we just record a location as often as possible and then draw these points as a polyline directly onto the map, avoiding the need for any direction requests.

Upvotes: 1

antonio
antonio

Reputation: 18262

You can use waypoints https://developers.google.com/maps/documentation/directions/intro#Waypoints but take into account that the maximum allowed number of waypoints is 23

Upvotes: 1

Related Questions