How to get Address from Lat&Long using google API & JavaScript in Asp.net



Here we will see How to get Address from Latitude & Longitude using google API & JavaScript in Asp.net

HTML CODE:
<div>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
            window.onload = function () {
                var mapOptions = {
                    center: new google.maps.LatLng(23.030473, 72.47349810000003),
                    zoom: 14,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var infoWindow = new google.maps.InfoWindow();
                var latlngbounds = new google.maps.LatLngBounds();
                var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
                google.maps.event.addListener(map, 'click', function (e) {
                    var latlng = new google.maps.LatLng(e.latLng.lat(), e.latLng.lng());
                    var geocoder = geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ 'latLng': latlng }, function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            if (results[1]) {
                                alert("Location: " + results[1].formatted_address + "\r\nLatitude: " + e.latLng.lat() + "\r\nLongitude: " + e.latLng.lng());
                            }
                        }
                    });
                });
            }
        </script>
        <div id="dvMap" style="width: 400px; height: 400px">
        </div>
    </div>


Related Posts

Previous
Next Post »

Thanks for comments.....