如何在谷歌地图顶部添加文本,以便平移时文本不会移动
我正在开发一个 HTML5 应用程序,旨在运行占据手机整个屏幕的 Google 地图。为了简单的调试,也许以后为了合法的信息目的,我想在地图的右下角放置一些文本,它报告一些信息,例如用户当前的纬度/经度。我查看了 v3 API,据我所知,其中没有任何内容可以执行此操作。有什么解决方法可以做到这一点吗?
I am working on a HTML5 application designed to run a Google map which takes up the entire screen on a mobile phone. For the sake of simple debugging, and perhaps later for legitimate informational purposes, I would like to position some text in the bottom right hand corner of the map, which reports some information, such as the current lat/lng of the user. I have looked through the v3 API, and to the best of my knowledge there's nothing in there to do this. Is there any kind of workaround that would permit this to be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
真的很容易。添加一个 div 作为控件。在 html 中的任意位置定义一个空 div。将其添加为控件,然后“地图”将其吸入地图显示中。然后使用您想要的任何 DOM 函数写入它。
希望这足以让大家理解这个想法。
在我的示例中,我将其放在 RIGHT_BOTTOM 中。其他选项位于此处。
跳过
Pretty easy really. Add a div as a control. Define an empty div anywhere in your html. Add it as a control, and Maps sucks it into the map display. Then write to it with any DOM functions you wish.
Hope that is enough to get the idea across.
In my example I put it in RIGHT_BOTTOM. Other options are here.
Skip
实现覆盖可能需要太多工作。出于调试目的,您最好使用 FireBug(或类似工具)的控制台日志记录选项。至于合法信息,如果它是特定于地理位置的,您可以使用 信息窗口。
如果数据不是特定于地理的,则最好将其显示在地图之外(您可以将其大小调整为 < 100%)。希望有帮助。
It might be too much work to implement an overlay. For debugging purposes, you're better off using the console logging options from FireBug (or a similar tool). As for the legitimate information, if it's geo-specific, you could use the InfoWindow.
If the data isn't geo-specific, it's probably best displayed outside of the map (You could resize it to be < 100%). Hope that helps.