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

后端 未结 2 1527
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 20:59

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

2条回答
  •  心在旅途
    2021-01-05 21:40

    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 here http://chart.googleapis.com/chart?chst=d_map_spin&chld=0.5|0|FF8800|15|_|

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

    enter image description here http://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
    ));
    

提交回复
热议问题