如何在 Google 地图 v2 中将标记放置在地图底部?
我有一个网页,通过邮政编码或名称查找商店。
我刚刚发布了更新,以便联系方式详细信息显示在来自标记的信息窗口中。由于信息窗口尺寸较小,以标记为中心后,地图会向下平移,直到适合标记和信息窗口,将标记保留在底部附近。
想知道是否有一种简单的方法可以立即设置此偏移量,以便标记出现在地图窗口的底部并且不必平移?
谢谢。
I have a webpage that finds a store by postcode or name.
I have just released an update to it so that contact details display in an info window coming from the marker. Due to the small size of the info window, after centering to the marker, the map pans down until it can fit the marker and info window in leaving the marker near the bottom.
Wondering if there is an easy way to set this offset immediately so that the marker appears at the bottom of the map window and it doesn't have to pan?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在添加标记之前,您可以将地图适当居中:
缩放也是可选的。您可以将缩放保留在任何位置:
如果您想以特定像素为中心,而不是纬度/经度,那么您可以使用此函数进行转换:
我觉得您应该花半个小时并查看文档:http://code.google.com/apis/maps/documentation/参考.html。我在网站上工作时广泛阅读了文档:www.trailbehind.com
You could center the map appropriately before you add the marker:
The zoom is optional too. You can just leave the zoom on whatever it is:
If you would like to center on a particular pixel, instead of a lat/lng, then you can use this function to convert:
I feel like you should spend half an hour and review the docs: http://code.google.com/apis/maps/documentation/reference.html. I read the documentation extensively while working on my website: www.trailbehind.com
自动平移可能是由内部 addoverlay 事件 处理程序。您是否尝试过处理
addoverlay
事件并从中返回 false?其中“map”是 GMap2 对象的名称。
Perhaps the auto-panning is caused by an internal addoverlay event handler. Have you tried handling the
addoverlay
event and returning false from it?where 'map' is the name of your GMap2 object.