0

行。我想要的是以下内容:我想用 jquery 控制标记的鼠标悬停。

我怎样才能做到这一点?我没有纯js的经验。(而且我不想使用 jquery 插件)

我试过这个:

google.maps.event.addListener(marker, 'ggmouseover', function() {
            marker.setIcon(pinred);
        });

        ggmouseover.mouseover();

这不起作用。(它适用于'mouseover'而不是'ggmouseover')我想创建一个函数或稍后可以通过jquery调用的东西。像:$('#button').mouseover(function(){ ggmouseover(); });

我怎样才能做到这一点?想法?

4

1 回答 1

4

你可以通过使用来做到这一点:

trigger(instance:Object, eventName:string, var_args:*)

触发给定的事件。eventName 之后的所有参数都作为参数传递给侦听器。

对于您的情况,这给出了:

google.maps.event.addListener(marker, 'mouseover', function() {
    marker.setIcon(pinred);
});

$("#button").mouseover(function() {
    google.maps.event.trigger(marker, 'mouseover');
});
于 2012-09-05T10:58:13.913 回答