<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 600px; height: 800px;"></div>
<script type="text/javascript">
var locations = [
['address 1', latitude coordinate, longitude coordinate, 1],
['address 2', latitude coordinate, longitude coordinate, 2],
['address 3', latitude coordinate, longitude coordinate, 3],
...
['address 58', latitude coordinate, longitude coordinate, 58],
['address 59', latitude coordinate, longitude coordinate, 59],
['address 60', latitude coordinate, longitude coordinate, 60],
,
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(47.594, -122.249),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
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>
Q (1): Can addresses 1-5 have a green pin/marker while addresses 6-60 remain the default red pin/marker?
Able to change all pins to green, yellow, etc. using,
marker = new google.maps.Marker({
icon: 'http://...'
});
however that changes all rather than a select few (of pins/markers).