Hi I have a map where a large number of markers (100) drop on a custom google map. Currently the icon is set before running through loop of lat/long.
Based on the code below, is there a way to specify a different icon for a few specific locations be a different icon?
Thanks in advance
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var mapcenter = new google.maps.LatLng(###, ###);
var icon = {
url: 'URL-OF-ICON'
};
var houses = [
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###),
new google.maps.LatLng( ###, ###), <!-- I want these last two to be a different icon -->
new google.maps.LatLng( ###, ###) <!-- I want these last two to be a different icon -->
];
var markers = [];
var iterator = 0;
var map;
function initialize() {
var mapOptions = {
zoom: 11,
center: mapcenter,
streetViewControl: false,
mapTypeControl: false,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
panControl: false
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
for (var i = 0; i < houses.length; i++) {
setTimeout(function() {
addMarker();
}, i * 50);
}
function addMarker() {
markers.push(new google.maps.Marker({
icon: icon,
position: houses[iterator],
map: map,
draggable: false,
animation: google.maps.Animation.DROP
}));
iterator++;
}
google.maps.event.addDomListener(window, 'load', initialize)
</script>