puma91
puma91

Reputation: 386

Create a route using a list of coordinates in Google Maps

I have a list of lat,lon coordinates as result of tracking a bus. I'm showing the route using PolyLine to create a line to connect "the dots" but because of the accuracy these dots aren't exactly by the street, and when you zoom in it is more obvious.

What can I do to show the route by the street?

This is what I have right now (There are 2 lines because the bus did 2 turns. It won't show like this in the final product) enter image description here

And this is what I need. enter image description here

Thanks for your help.

Upvotes: 4

Views: 5510

Answers (2)

MymsMan
MymsMan

Reputation: 193

Search for 'snap polyline to road using google maps api v3' for similar discussions.

There doesn't appear to be a straightforward API service to do this and you would need to reduce your route to significant changes in direction rather than every wiggle.

You might add a star to the issue in the 'Google Maps API bug reports and feature requests' database http://code.google.com/p/gmaps-api-issues/issues/detail?id=3824 and possibly add a new issue since your problem is somewhat different

Upvotes: 2

geocodezip
geocodezip

Reputation: 161384

I would suggest reducing the polylines to the minimum number of waypoints required to make the DirectionsServide create the same route.

example from this similar question

example using coordinates rather than addresses

Upvotes: 3

Related Questions