Google Maps API v3 - 在过去一周左右发生了变化?

时间:2010-12-21 13:34:25

标签: javascript api google-maps geocoding

我使用以下代码从用户输入中获取lat和lng值。它似乎工作正常,直到最近。

if (status == google.maps.GeocoderStatus.OK) {
    var lat = parseFloat(results[0].geometry.location.wa).toFixed(3);
    var lng = parseFloat(results[0].geometry.location.xa).toFixed(3);
    ....

现在,如果我是console.log results[0].geometry.location,我会得到(51.4793388, -2.5933342) { va=51.4793388, wa=-2.5933342}

好像xa已更改为va引用这些值的正确方法是什么?

1 个答案:

答案 0 :(得分:5)

我最近在Google Map API 3.0应用程序上遇到了同样的问题。基本上,如果我没记错的话,wa和xa变量只是LatLng()变量。所以你可以用这种方式打电话给他们:

results[0].geometry.location.lat().toFixed(3);
results[0].geometry.location.lng().toFixed(3);

其中va = lat和wa = lng