Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
997 views
in Technique[技术] by (71.8m points)

google maps api 3 - item.geometry.location.kb & item.geometry.location.jb returning undefined

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;
...
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...