Google地图地理编码:未定义的纬度

Jor*_*eno 0 google-maps geocoding

点击跟随脚本的页面显示:

  • lat:undefined
  • Lon:51.5001524

为什么当lat未定义时,lon不是?可以在这里找到一个工作示例.

拉起你的网络控制台,亲眼看看吧!

$(document).ready(function(){

var geocoder;
function codeAddress() 
{
    geocoder = new google.maps.Geocoder();
    var address = 'London, England';
    geocoder.geocode({'address': address}, function(results, status) 
    {   
      if (status == google.maps.GeocoderStatus.OK) 
      {
        lat = results[0].geometry.location.Ia;
        lon = results[0].geometry.location.Ja;

        console.log("lat: " + lat);
        console.log("lon: " + lon);
      }
    });
}
    codeAddress();
});
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我们在这里 - Ia和Ja的历史意义是什么?我认为它涉及笛卡尔单位向量i和j(主要用于工程),虽然我不确定.

我在网上找到了其他使用.latfor .Ia.lngfor的例子.Ja

但是,这些会在控制台中返回:

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

只需要朝正确的方向发起冲击.谢谢.

Jir*_*riz 5

我会用lat()lng():

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