doulu6234 2019-03-05 16:49
浏览 269

查找邮政编码| Zipcode使用谷歌地图地理编码反向

Find Postal Code | Zipcode using Google map geocoding reverse.

I want this functionality. Please check screenshot.

https://snag.gy/IAaZmr.jpg

I just want to fetch pincode for the ewspective google location using google api geocoding

  • 写回答

1条回答 默认 最新

  • dqroktbn005028 2019-03-06 14:31
    关注
    function callZipAPI(addSearchZip){    
    var geocoder = new google.maps.Geocoder();
    var zipCode = null;
    
    geocoder.geocode({ 'address': addSearchZip }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
    
            //var latitude = results[0].geometry.location.lat();
            //var longitude = results[0].geometry.location.lng();
    
            var addressComponent = results[0].address_components;            
            for (var x = 0 ; x < addressComponent.length; x++) {
                var chk = addressComponent[x];
                if (chk.types[0] == 'postal_code') {
                    zipCode = chk.long_name;
                }
            }
            if (zipCode) {
                alert(zipCode);
            }
            else {
                alert('No result found!!');
            }
        } else {            
            alert('Enter proper address!!');
        }
    });}
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记