开发者

Google Maps Marker Click Event Bubbling

开发者 https://www.devze.com 2023-03-07 23:54 出处:网络
I have a marker on a Google Map using the v3 Javascript API that is beneath an开发者_高级运维other marker.When I click on the topmost marker, I would like to have the click event bubble up (down?) to

I have a marker on a Google Map using the v3 Javascript API that is beneath an开发者_高级运维other marker. When I click on the topmost marker, I would like to have the click event bubble up (down?) to the bottom-most marker with the goal of providing an optional menu for the user to choose which marker they meant to click.

Is this possible with the google.maps.event.addListener for click events?

Can I query the map for all markers that are contained by a given location, apart from hacking it myself?


As far as I know there isn't a builtin way to cycle through the markers on the click event. You can control the zIndex of each marker via the MarkerOptions which will override the default stacking based on vertical position:

All markers are displayed on the map in order of their zIndex, with higher values displaying in front of markers with lower values. By default, markers are displayed according to their vertical position on screen, with lower markers appearing in front of markers further up the screen.

It think you will have to code this up yourself. I would love to hear how that goes.

0

精彩评论

暂无评论...
验证码 换一张
取 消