Reputation: 632
I use AutocompleteService.getPlacePredictions method to get autocomplete items for my drop down. Very often that method returns "long" placeIds that look like this (actual placeId):
ChIJx55rzdwQ9YgRHB-NARRWZyuaBjAxNzExIERvbm5hIEx5bm4gRHJpdmUsIFNteXJuYSwgR0EsIFVuaXRlZCBTdGF0ZXM
If I then try to pass that place ID to Geocoder I get status of ZERO_RESULTS and no places:
new google.maps.Geocoder().geocode(
{ placeId: "thatLongPlaceId"},
function (results, status) { /* no place data returned */ });
But at the same time if I make the following GET call the same placeId returns the expected address:
https://maps.googleapis.com/maps/api/place/details/json?key=MyApiKey&placeid=ChIJx55rzdwQ9YgRHB-NARRWZyuaBjAxNzExIERvbm5hIEx5bm4gRHJpdmUsIFNteXJuYSwgR0EsIFVuaXRlZCBTdGF0ZXM
What am I doing wrong? What's the proper way of using that long place ID to get place data?
Upvotes: 1
Views: 928
Reputation: 11
The ZERO_RESULTS problem isn't because of the long place ids. To see this, try using the (long) place id from an autocomplete result for an address in Sydney, for e.g.
ChIJr-__yjeuEmsR3RMEBNOoUn-aBjQ0OCBQaXJyYW1hIFJvYWQsIFB5cm1vbnQsIE5ldyBTb3V0aCBXYWxlcywgQXVzdHJhbGlh
The call to Geocoder.geocode should return 1 result.
Long story short, the Geocoding API (that google.maps.Geocoder uses) hasn't been fixed for the problem in https://code.google.com/p/gmaps-api-issues/issues/detail?id=11107.
Upvotes: 1
Reputation: 104
I think the autocomplete endpoint is not returning valid placeids as of today or yesterday. I'm running into a similar problem.
See Google Place Autocomplete API returning wrong place id
Upvotes: 1