google api geocoding返回与官方文档不同的json对象

ter*_*ing 5 geocoding google-maps-api-3

我已经成功地使用谷歌api进行地理编码,但是当我最初设置它时,我注意到返回的对象与谷歌文档中描述的不完全相同:https://developers.google.com/maps/文档/地理编码/#GeocodingResponses

我用console.dir检查chrome中的对象.

除非我误解(很可能),否则我可以检索所提供地址的纬度和经度,如下所示:

lat = results[0].geometry.location.lat;
lng = results[0].geometry.location.lng;
Run Code Online (Sandbox Code Playgroud)

除了,那是行不通的,当我调查时,我发现lat和lng分别处于results[0].geometry.location.d和results[0].geometry.location.e.

直到今天它都停止了工作.调查我发现lat&lng正在通过results[0].geometry.location.k&返回results[0].location.A.

据推测,这将在不久之后再次破裂.

如果我检查结果[0] .geometry.location.lat它包含:

function (){
\"use strict\";
return this[a]}
Run Code Online (Sandbox Code Playgroud)

有人认识到了吗?

Dr.*_*lle 15

从Javascript-Geocoder的地理编码方法返回的结果已经被翻译为与Javascript-API一起使用(链接文档用于Geocoding-Webservice,而不是Maps-Javascript-API).

geometry.location 不是一个普通的对象,它是一个 google.maps.LatLng

您必须使用方法lat()和lng()的geometry.location检索经度和纬度.

地理编码器几何规范

在你的情况下,这将意味着像这样使用它:

lat = results[0].geometry.location.lat(); 等等