简体   繁体   English

在JQuery中使用Google Maps Api事件/侦听器

[英]Use Google Maps Api Event/Listener in JQuery

ok. 好。 what i want is the following: i want to control a mouseover of a marker with jquery. 我想要的是以下内容:我想用jquery控制标记的鼠标悬停。

how can i do that? 我怎样才能做到这一点? i have no experience with pure js. 我没有纯js的经验。 (and i don't want to use a jquery-plugin) (而且我不想使用jQuery插件)

i tried this: 我尝试了这个:

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

        ggmouseover.mouseover();

this does not work. 这行不通。 (it works with 'mouseover' instead of 'ggmouseover') i want to create a function or something i can call later through jquery. (它与'mouseover'而不是'ggmouseover'一起工作)我想创建一个函数或以后可以通过jquery调用的东西。 like: $('#button').mouseover(function(){ ggmouseover(); }); 例如: $('#button').mouseover(function(){ ggmouseover(); });

how can i do this? 我怎样才能做到这一点? ideas? 想法?

You can do it by using : 您可以使用:

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

Triggers the given event. 触发给定事件。 All arguments after eventName are passed as arguments to the listeners. eventName之后的所有参数都作为参数传递给侦听器。

Which gives, for your case : 对于您的情况,给出了:

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

$("#button").mouseover(function() {
    google.maps.event.trigger(marker, 'mouseover');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM