【问题标题】:Function to get Longitude and Latitude from Location using Javascript [duplicate]使用Javascript从位置获取经度和纬度的函数[重复]
【发布时间】:2014-05-20 10:20:55
【问题描述】:

我的功能是这样的。

function getLatLong(address){
    var latitude="";
    var geocoder =  new google.maps.Geocoder();

    geocoder.geocode( { 'address': address}, function(results, status) {
        latitude = results[0].geometry.location.lat();
        alert(latitude);
});
   return latitude;
}


  alert(getLatLong(co));

当我调用此函数时,我得到空结果,但函数中的警报返回纬度。有什么问题?

【问题讨论】:

标签: google-maps


【解决方案1】:

我认为这个问题中的操作答案可能会有所帮助:

Google maps geocode API V3 not returning result in javascript function

正如您在解决方案中看到的,操作使用来自 geocoder.geocode 的回调。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-08
    • 2017-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多