『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

Google Map另外一种方法实现经纬度转换成具体地址(google.maps.Geocoder)

Google Map另外一种方法实现经纬度转换成具体地址(google.maps.Geocoder)
在之前Google map geocode服务将经纬度转换成具体地址(js)中,我使用google map 自带的反向地址解析完成,采用jquery解析Google Map的geocode地址数据

       在之前Google map geocode服务将经纬度转换成具体地址(js)中,我使用google map 自带的反向地址解析完成,采用jquery解析Google Mapgeocode地址数据。但是jquery可能许多人不熟悉,这里提供一种Google Map自带的方法。

 

       核心代码如下:

 

var geocoder = new google.maps.Geocoder();

geocoder.geocode( { 'location': myLatlng}, function(results, status) {

    if (status == google.maps.GeocoderStatus.OK) {

        map.setCenter(myLatlng);

        infowindow = new google.maps.InfoWindow({

            content: results[0].formatted_address,

            maxWidth: 200

        });

    } else {

      alert('Geocode was not successful for the following reason: ' + status);

    }

});

       效果如图:

 

 

 

       点击这里在线预览 猛击这里下载这个demo

      京ICP备2025132830号-1 京公网安备 号