Google Places API why does it returns Lat and Lon under a different variable each time?

后端 未结 1 439
没有蜡笔的小新
没有蜡笔的小新 2021-01-24 16:15

This is driving me nuts, for some reason the API used to return the Lat and Lon like this: (I think it was like this):

place.geometry.location.y as Latitude

相关标签:
1条回答
  • 2021-01-24 16:41

    place.geometry.location consists by LatLng class. So if you want to get Latitude/Longitude, you should use like this code:

    var lat = result[0].geometry.location.lat();
    var lng = result[0].geometry.location.lng();
    

    And the reference of the place.geometry.location is here. https://developers.google.com/maps/documentation/javascript/reference#PlaceGeometry

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