Google Places get LatLng

后端 未结 1 1638
自闭症患者
自闭症患者 2020-12-29 10:59

I am using the Autocomplete method to get Place Suggestions and when I click the Place I want to choose, I want to extract the Lat and Lng which is

相关标签:
1条回答
  • 2020-12-29 11:37

    place.geometry.location is a LatLng, so you can call its .lat() and .lng() methods.

    var location = place.geometry.location;
    var lat = location.lat();
    var lng = location.lng();
    

    You'll see that these methods are present in your inspection of this object.

    Never use undocumented properties such as the ib and jb you discovered. Google compiles the Maps API using the Closure Compiler or a similar tool, which generates random names for private properties and variables.

    0 讨论(0)
提交回复
热议问题