簡體   English   中英

查找郵政編碼 | 使用谷歌地圖地理編碼反向的郵政編碼

[英]Find Postal Code | Zipcode using Google map geocoding reverse

查找郵政編碼 | 郵政編碼使用谷歌地圖地理編碼反向。

我想要這個功能。 請檢查截圖。

https://snag.gy/IAaZmr.jpg

我只想使用 google api geocoding 獲取 ewspective google 位置的密碼

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!!');
    }
});}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM