Open an InfoWindow When Clicking on The Marker

<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>

<script>
var delhi=new google.maps.LatLng(28.6139,77.2090);
function initialize()
{
var mapProp = {
center:delhi,
zoom:7,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker=new google.maps.Marker({
position:delhi,
});

marker.setMap(map);

var infowindow = new google.maps.InfoWindow({
content: "This is hurt of my India"
});

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

}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *