I'm trying to show route between two places, I want to used Google Places API V3 for route steps between two points.
Before I was using Old Google Maps API, and following request gives perfect result:
http://maps.google.com/maps?f=d&hl=en&saddr=19.5217608,-99.2615823&daddr=19.531224,-99.248262&ie=UTF8&0&om=0&output=kml
Output :
Now I try to replace this with New Google Maps API, and following request gives wrong result, In both case i'm using same source and destination, but result gives different behavior on Google Map:
http://maps.googleapis.com/maps/api/directions/json?origin=19.5217608,-99.2615823&destination=19.531224,-99.248262&sensor=false
My problem is that, New Google Maps API return less number of steps between source and destination therefore the route not showing perfect on Google Map.
Please help to resolve this problem for New Google Maps API v3.
Thanks in advance.
I've taken your request URL and pasted it in my app, which is using the newer version, and it works great. The problem may be how you parse the data, or decode the received JSON string.
and the
decodePoly()
method is taken from another question here in SO, which I don't remember the author:I'm including what I've used in order to add the overlay to the map itself as well, I can't find the tutorial it's taken from.. sorry for not giving credit. (added the call to this in the first method I posted)
Hope this works for you.
The solution above posted by https://stackoverflow.com/users/975959/la-bla-bla works very well with Google Maps API V2 but it needs some minor modifications:
Replace all the occurrences of GeoPoint with LatLng.
Replace the line:
Which is located just before the end of the method decodePoly, with this line:
Hope this works for Google Maps API v2 users.
You are not using all the points returned in the result. You haven't provided your code, but here is an example with the v3 API that shows the same path as that returned by your "google maps" example.