Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make google map marker grow bigger when the mouseover it?

In Google Map API v3, as the title, I only saw 2 types of animation in google map api, but I saw in some places the map marker animate like grow big when mouse over it? How to implement this?

like image 894
xmurobi Avatar asked Nov 24 '11 13:11

xmurobi


People also ask

How do you customize a marker in maps?

For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.

How do I move a marker smoothly on Google Maps?

The transition() and moveMarker() are used to move marker smoothly on click on the Google map.


2 Answers

Use marker's mouseover event handler and setIcon() method. You can use dynamic icons from google chart api for this purpose, and change the chld attribute to make the icon grow:

enter image description herehttp://chart.googleapis.com/chart?chst=d_map_spin&chld=0.5|0|FF8800|15|_|

enter image description herehttp://chart.googleapis.com/chart?chst=d_map_spin&chld=0.6|0|FF8800|15|_|

enter image description herehttp://chart.googleapis.com/chart?chst=d_map_spin&chld=0.7|0|FF8800|15|_|

Don't forget to set proper anchor point! For example:

marker.setIcon(new google.maps.MarkerImage(
    'http://chart.googleapis.com/chart?chst=d_map_spin&chld=0.65|0|FF8800|15|_|',
    null,
    null,
    new google.maps.Point(11, 43) // this is the proper anchor point for scale 0.65
));
like image 110
Tomas Avatar answered Oct 18 '22 21:10

Tomas


You could use your own image as a marker, then make use of the scaledSize property for the marker image to make it bigger when the mouseover event fires.

I don't know of a way to do this without doing some more complicated stuff like this.

like image 36
Oliver Avatar answered Oct 18 '22 20:10

Oliver