wazzaday
wazzaday

Reputation: 9664

Google maps autocomplete api v3 suddenly stopped working

So I was surprises to find after changing no code at all that the Google Maps auto-complete API suddenly stopped working. I logged out the results to see what was happening.

I had previously been getting a lat lng from an auto-completed address as follows:

new google.maps.LatLng(from_autocomplete.getPlace().geometry.location.d, from_autocomplete.getPlace().geometry.location.e);

the d and e being the lat and lng coords. I found the error to be that the response from the autocomplete object (autocomplete.getPlace().geometry.location) is now:

k: 53.002668, A: -2.179403999999977

Why would the d and e suddenly change to a K and A? It had been working for weeks and then this changed without notice.

Upvotes: 2

Views: 3419

Answers (2)

Hassan Saeed
Hassan Saeed

Reputation: 7130

I have had similar problem. Google maps and autocomplete suddenly not working then i follow these steps

-make "YOUR_API_KEY" from google developer console (https://console.developers.google.com) then enable following things(with Enable button) for current project in developer console

Google Maps JavaScript API
Google Places API Web Service Google
Maps Geocoding API
Google Maps Geolocation API (these are important features you can also enable other features if you want)

after that my problem solved

Upvotes: 1

Anto Jurković
Anto Jurković

Reputation: 11258

You used properties of internal object structure which can change any time.

geometry is google.maps.places.PlaceGeometry type with property location which is a google.maps.LatLng class. You can get latitude and longitude using officially supported lat() and lng() methods.

Upvotes: 3

Related Questions