google maps - Finding distance using place id -


as per documentation, retrieve distance between set of origins , destinations in following manner (server api).

https://maps.googleapis.com/maps/api/distancematrix/json?origins=washington%20dc&destinations=new%20york&mode=walking&key= 

instead of passing place names, better if pass place_id origin or destination. give more accurate results. possible ?

for eg. possible perform api call like:

https://maps.googleapis.com/maps/api/distancematrix/json?origins=<place_id>&destinations=<place_id>&mode=walking&key= 

???

thankyou

there no ways let google use place_id origins, or destinations in google maps direction api.

so way lat/lng or address place_id first. can by:
1) reverse geocoding: https://developers.google.com/maps/documentation/geocoding/

https://maps.googleapis.com/maps/api/geocode/json?place_id=chij2eugeak6j4arbn5u_wagqwa&key=mykey

2) place details: https://developers.google.com/places/webservice/details

https://maps.googleapis.com/maps/api/place/details/json?placeid=chij2eugeak6j4arbn5u_wagqwa&key=mykey

update

now can apply place ids origins , destinations in distance matrix api.

if supply place id, must prefix place_id:. can specify place id if request includes api key or google maps apis premium plan client id.

please refer documentation further details:

https://developers.google.com/maps/documentation/distance-matrix/intro#requestparameters


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -