Reputation:
I'm using getQueryPredictions method to get autofill entries. The value of place_id
in about 10% of returned places is a 40 characters long string that starts with "E". I'm trying to pass that place_id
to google.maps.DistanceMatrixService().getDistanceMatrix
method to get a distance between those places and other "normal" locations but Google does not return anything for such IDs.
You can easily get such "E" place_id
if you use address "4498 INTERSTATE NORTH PARKWAY EAST SOUTHEAST" at this form from Map API Documentation It returns "EjM0NDk4IEludGVyc3RhdGUgTiBQa3d5IEUgU0UsIEF0bGFudGEsIEdBIDMwMzM5LCBVU0E" as place_id
. Use that ID in any other Maps API mathods and Google won't recognize it as a valid place_id.
How can I use those weird IDs to look up distances? Or how can I transform them into normal place_ids
?
Upvotes: 0
Views: 1013
Reputation: 2998
I created an API key and used the referred place_id
, which returned a valid response.
https://maps.googleapis.com/maps/api/place/details/json?placeid=EjM0NDk4IEludGVyc3RhdGUgTiBQa3d5IEUgU0UsIEF0bGFudGEsIEdBIDMwMzM5LCBVU0E&key=[API_KEY]
Its not specified, but not all Google Maps API can be used with place_id
.
You can use the same place ID across the Google Places API and a number of Google Maps APIs. For example, you can use the same place ID to reference a place in the Places API, the Google Maps JavaScript API, the Google Maps Geocoding API, the Google Maps Embed API and the Google Maps Roads API.
For your getDistanceMatrix
to work, your destinations[]
should either be string, LatLng
, or Place
objects. You'll have to use the place_id
to get the place details (which has the LatLng
that you can use for getDistanceMatrix
).
Upvotes: 1