Can I change marker size on hover? I need increase marker size on hover (2-3 px) and decrease to default size on mouse out.
If you use a custom-icon, you can easyly change the image on mouse-over :
[...]
var marker_image_medium = new google.maps.MarkerImage('medium.png');
var marker_image_big = new google.maps.MarkerImage('big.png');
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: marker_image_medium,
title: "Exemple"
});
google.maps.event.addListener(marker, 'mouseover', function() {
marker.setIcon(marker_image_big);
});
google.maps.event.addListener(marker, 'mouseout', function() {
marker.setIcon(marker_image_medium);
});
This is a partial example, you have to init the map, declare myLatlng, etc.
Edit : oups, small error on setIcon(), corrected.
you need to change
google.maps.event.addListener(marker, 'mouseout', function() {
marker.setIcon(marker_image_medium);
});
to
google.maps.event.addListener(marker, 'mouseout', function() {
this.setIcon(marker_image_medium);
});
here is the correct way to change the image on mouseover and mouseout.
inside the function need to use this instead of marker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With