如何获取Google Maps标记的HTML DOM元素? [英] How to obtain the HTML DOM element of a Google Maps marker?

查看:126
本文介绍了如何获取Google Maps标记的HTML DOM元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个GMarker JS变量,如何获取代表它的HTML DOM元素?我需要这个,所以我可以使用正确的z-索引将我自己的< div> 插入到地图中。



谢谢。

解决方案

看起来Google Maps API没有提供返回标记的DOM元素的方法。



您只想创建自己的自定义标记?如果是这样,您可以创建一个扩展GOverlay的标记类。 MarkerLight 是一个很好的例子,说明如何完成这个(和以下是示例页面)。



如果您需要的是一个自定义图标,这里是如何做到的。


Given a GMarker JS variable, how do I obtain the HTML DOM element that represents it? I need this so I can insert a <div> of my own into the map with the correct z-index.

Thanks.

解决方案

It looks like the Google Maps API doesn't provide a method to return a marker's DOM element.

Do you just want to create your own custom marker? If so, you can create a marker class which extends GOverlay. MarkerLight is a great example of how to accomplish this (and here is the example page).

If all you need is a custom icon, here is how to do that.

这篇关于如何获取Google Maps标记的HTML DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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