item.geometry.location.kb & item.geometry.location

2019-01-09 19:50发布

问题:

I'm using google maps to get an autocomplete list of cities.

I used to use item.geometry.location.kb as the longitude and item.geometry.location.jb as the latitude but they are not defined since today/yesterday.

Apparently, one has to use item.geometry.location.lng() and .lat() instead.

I didn't know that and I have an app using item.geometry.location.kb & jb in google play and the app store.

So my apps are not working anymore.

Any idea on why a change has been made and how to revert to kb & jb ?

Thank you

autocomplete = new google.maps.places.Autocomplete(input, options);

google.maps.event.addListener(autocomplete, 'place_changed', function(event) {
        var item = autocomplete.getPlace();

       curLon = item.geometry.location.kb;
       curLat = item.geometry.location.jb;
...

回答1:

Don't use undocumented properties of the Google APIs. They can and do change with every release.

geometry.location is a google.maps.LatLng object, the documented methods to get latitude and longitude are .lat() and .lng().