Created
April 12, 2016 10:51
-
-
Save mort3za/cdb323abf1210dc9b2e79ded4656ba17 to your computer and use it in GitHub Desktop.
Google map with multiple markers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Google Maps Multiple Markers</title> | |
<meta charset="utf-8"> | |
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> | |
</head> | |
<body> | |
<div id="map" style="height: 400px; width: 100%; direction:rtl; text-align:right;"> | |
</div> | |
<script type="text/javascript"> | |
var locations = [ | |
['<span style="font-family:tahoma !important; font-size:12px; padding-right:25px;" >شرکت پاکشوما</span>', 35.733369, 51.416976, 4] | |
]; | |
var map = new google.maps.Map(document.getElementById('map'), { | |
zoom: 15, | |
center: new google.maps.LatLng(35.733369, 51.416976), | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
streetViewControl: false, | |
// navigationControl: false, | |
// mapTypeControl: false, | |
// scaleControl: false, | |
// zoomControl: false, | |
// draggable: false, | |
}); | |
var infowindow = new google.maps.InfoWindow(); | |
var marker, i; | |
for (i = 0; i < locations.length; i++) { | |
marker = new google.maps.Marker({ | |
position: new google.maps.LatLng(locations[i][1], locations[i][2]), | |
map: map | |
}); | |
google.maps.event.addListener(marker, 'click', (function(marker, i) { | |
return function() { | |
infowindow.setContent(locations[i][0]); | |
infowindow.open(map, marker); | |
} | |
})(marker, i)); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment