如何在Google地图上点击默认标记/地点时捕获点击事件? [英] How can i capture the click event when a default marker/place is clicked on googlemaps?

查看:533
本文介绍了如何在Google地图上点击默认标记/地点时捕获点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Maps API V3。谷歌地图默认显示某些地方/位置的标记,当点击其中一个时,我需要捕获点击事件。

我试图使用地图的点击事件,但它不起作用,因为用户点击标记而不是地图,代码给出:

  google.maps.event.addListener(mymap,'click',function(){
alert('clicked');
});

有人可以给我一个想法吗?



编辑:
我找不到合适的事件在可用事件中,这可以帮助我!



请注意,我不是在谈论自定义标记(由用户创建) ,这些都是默认标记,googlemaps默认显示它们。

解决方案

href =https://developers.google.com/maps/documentation/javascript/examples/event-poi =nofollow noreferrer> https://developers.google.com/maps/documentation/javascript/examples / event-poi



您可以轻松地自定义POI的默认infowindow。只要忽略教程的路线制作功能。


I am working with Google Maps API V3. The googlemaps displays markers for some places/location by default, I need to capture the click event when one of them is clicked..

I have tried to use the click event of the map but it not works because the user is clicking the marker not the map, code is given:

google.maps.event.addListener(mymap, 'click', function () {
  alert('clicked');
});

Can someone give me an idea how to do it?

EDIT: I can find no suitable Event in the available Events, which can help me!

Please note that I am not talking about the custom Markers (Created by User), these are default markers, googlemaps displays them by default.

解决方案

Here's a clean solution straight from Google: https://developers.google.com/maps/documentation/javascript/examples/event-poi

You can easily customize the default infowindow for POI's. Just ignore the route-making feature of the tutorial.

这篇关于如何在Google地图上点击默认标记/地点时捕获点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆