简体   繁体   English

HTML而不是谷歌地图标记图像

[英]html instead of google maps marker image

Is it possible to display HTML instead of an image as a Google Maps Marker ? 是否可以将Google而不是图像显示为Google Maps Marker?

What is the best way to do so? 这样做的最佳方法是什么? I imagine that something like an invisible marker and a custom info-window might play a role in achieving this 我想像隐形标记和自定义信息窗口之类的东西可能会在实现这一目标中发挥作用

You can use OverlayView class to create custom overlays with html elements - https://developers.google.com/maps/documentation/javascript/overlays#CustomOverlays 您可以使用OverlayView类创建包含html元素的自定义叠加层 - https://developers.google.com/maps/documentation/javascript/overlays#CustomOverlays

Simple example - http://jsfiddle.net/BCr2B/ 简单的例子 - http://jsfiddle.net/BCr2​​B/

You might want to check this out: https://github.com/jonyt/gmaps-div-overlay 您可能想要查看这个: https//github.com/jonyt/gmaps-div-overlay

DivOverlay is a very simple container for HTML to be shown over a Google Map at any position. DivOverlay是一个非常简单的容器,可以在任何位置通过Google Map显示HTML。 All it does is calculate margins from the map bounds so its entire contents are within the map. 它所做的就是从地图边界计算边距,使其整个内容都在地图内。 Take a look at the demo. 看看演示。 The constructor takes 3 arguments: the HTML container, the map to attach to and the position of the overlay. 构造函数有3个参数:HTML容器,要附加的映射以及叠加层的位置。 DivOverlay has only two functions: show() and hide(). DivOverlay只有两个函数:show()和hide()。 Should be self-explanatory. 应该是不言自明的。

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

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