📌  相关文章
📜  google map get lat long by pincode - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:10.787000             🧑  作者: Mango

代码示例1
function getLatLngByZipcode(zipcode){
        const coordinates = {Latitude: 22.973423, Longitude: 78.656894};    // Fallback coordinates in case of failure
        const geocoder = new google.maps.Geocoder();
        geocoder.geocode({ 'address': 'zipcode ' + zipcode }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                coordinates.Latitude = results[0].geometry.location.lat();
                coordinates.Longitude = results[0].geometry.location.lng();
            } else {
                console.log("google.maps.Geocoder request failure.")
            }
        });
        return coordinates;
}