【问题标题】:How can I make google map marker grow bigger when the mouseover it?鼠标悬停时如何使谷歌地图标记变大?
【发布时间】:2012-01-05 15:42:43
【问题描述】:

在 Google Map API v3 中,如标题所示,我在 google map api 中只看到了 2 种类型的动画,但我在某些地方看到地图标记的动画就像鼠标悬停时变大一样?如何实施?

【问题讨论】:

    标签: google-maps animation google-maps-api-3 google-maps-markers


    【解决方案1】:

    使用标记的鼠标悬停事件处理程序和setIcon() 方法。为此,您可以使用来自 google chart api 的 dynamic icons,并更改 chld 属性以使图标变大:

    http://chart.googleapis.com/chart?chst=d_map_spin&chld=0.5|0|FF8800|15|_|

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

    http://chart.googleapis.com/chart?chst=d_map_spin&chld=0.7|0|FF8800|15|_|

    别忘了设置合适的锚点!例如:

    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
    ));
    

    【讨论】:

    • 自 2012 年起,此功能已弃用。有谁知道这个的现代解决方案?
    • 如果你只是点击你自己的链接,你会看到。 ;)
    【解决方案2】:

    您可以使用自己的图像作为标记,然后使用标记图像的scaledSize 属性使其在mouseover 事件触发时变大。

    如果不做一些更复杂的事情,我不知道如何做到这一点。

    【讨论】:

    • 你想明白了吗? +1 如果它真的有效.. 请告诉我
    • @mmmshuddup 对不起,我已经有一段时间没有研究这个了。一年多过去了,您可能会发现 API 从那时起发生了变化/改进。
    猜你喜欢
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-09
    • 2012-02-13
    相关资源
    最近更新 更多