Google Map API: Google map not displayed for specific Zip (Postal) Code in ASP.Net

Last Reply 5 months ago By dharmendr

Posted 5 months ago

hello,

i am using this google map code based on post code it shows map

 

this zipcode is valid GA 30340    USA zipcode i test it on google map and it shows result but i use this zipcode GA 30340 in below code it does not return the map

 

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places&key=AIzaSyCEe5-E20uazeOIHsuQUOJKBM4-ZQ_ETEs"></script>
<script type="text/javascript">
    window.onload = function DrawMap() {
        var geocoder = new google.maps.Geocoder();
        var address = document.getElementById("<%=HiddenField1.ClientID %>").value;
        geocoder.geocode({ 'address': address }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var latitude = results[0].geometry.location.lat();
                var longitude = results[0].geometry.location.lng();
                var data = {};
                data.title = results[0].formatted_address;
                data.lat = latitude;
                data.lng = longitude;
                var mapOptions = { center: new google.maps.LatLng(latitude, longitude), zoom: 12, mapTypeId: google.maps.MapTypeId.ROADMAP };
                var infoWindow = new google.maps.InfoWindow();
                var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
                var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                var marker = new google.maps.Marker({ position: myLatlng, map: map, title: data.title });
                (function (marker, data) {
                    google.maps.event.addListener(marker, "click", function (e) {
                        infoWindow.setContent("<div style = 'width:200px;height:50px'>" + data.title + "</div>");
                        infoWindow.open(map, marker);
                    });
                })(marker, data);
            } else {
                alert("Your post code is not correct please update your correct postcode.")
            }
        });
    };
</script>
<%--<input name="txtPostalCode" type="text" value="400093" id="txtPostalCode" />
<input type="submit" value="Draw Map" onclick="DrawMap(); return false;" />--%>
<br />
<div id="dvMap" style="width: 300px; height: 400px">
</div>

 

Posted 5 months ago

Hi nauna,

That means the zipcode is not listed in the google api. So we can't do any thing for this.

You can ask the same in the official forums and raise an issue there.