Pages

April 11, 2012

Show Google Map In ASP.Net

How to display Google Map in ASP.Net Application?
We need to call Google Map and accordingly we can organize it on presentation.

<script type="text/javascript"src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script
>
<script language="javascript" type
="text/javascript">

        varmap;
        vargeocoder;
        functionInitializeMap() {

            varlatlng = new google.maps.LatLng(0, 0);
            varmyOptions =
        {
            zoom: 8,
            center: latlng,
            mapTypeId:google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true,
            draggable:false,
        };
            map = new google.maps.Map(document.getElementById("map"), myOptions);
        }
function ShowMap() {
            geocoder = new google.maps.Geocoder();
            InitializeMap();

            geocoder.geocode({ 'address': 'New Delhi'}, function(results, status) {
                if(status == google.maps.GeocoderStatus.OK) {
                   map.setCenter(results[0].geometry.location);
                    var marker = newgoogle.maps.Marker({
                        map: map,
                        position:results[0].geometry.location
                    });
                    if (results[0].formatted_address) {
                        region =results[0].formatted_address + '';
                    }
                    var infowindow = newgoogle.maps.InfoWindow({content: 'New Delhi'});
                    infowindow.open(map,marker);
                   

                    google.maps.event.addListener(marker,'click', function(){
                    infowindow.open(map,marker);
                       
                    });

                }
                else{
                    alert("Geocode was not successful for the following reason: " + status);
                }
            });


        }

<body onload="InitializeFB();">

<formid="form1"runat="server">

<div  id="map"style="height: 400px;width: 98%;">
</div>

</body>

That's It.
Enjoy Learning.


 

3 comments:

Post a Comment