I am aware that officially google removed shadows on markers in v3 of the google maps API. With this is in mind i have a project where marker shadows are required. I would like to place a shadow on a marker when the marker is clicked. Its essentially add an event listener to a marker and when its clicked add a shadow to the marker as a way to show that the clicked marker is the active marker.
I read through some pages e.g. marker shadows in google maps v3 which put shadows on all markers but I would like to borrow on such an example and have the shadows added when a marker is clicked and have the shadows removed when the marker loses focus i.e. when another marker is clicked.
My jsfiddle with two markers to play with is here and code is below: jsfiddle is here
var marker;
var locations = [["6","43.683","9.58","3002: Location 1",1],["7","45.149","9.44","3003: Location",2]];
function initialize() {
var mapProp = {
center: new google.maps.LatLng(43.683, 9.44),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position:new google.maps.LatLng(locations[i][1], locations[i][2]),
icon:'https://maps.gstatic.com/mapfiles/ms2/micons/purple.png',
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
alert(locations[i][3] + " was clicked");
}
})(marker, i));
marker.setMap(map);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
If anyone can help with coming up with a strategy or even a code snippet to place shadows on a marker when its clicked I would be very happy. Please feel free to fork the jsfiddle and add to it and post the link back here.