Google 地图 API:标记图像定位
我更改了 Google 地图上用于标记
的图像。新图像比旧图像宽得多,我注意到标记与 lat
和 lng
对齐,以便标记位于 lat
上方的水平中点。代码>lat 和lng
。这不是我想要的,我想让 lat
和 lng
与标记左侧对齐 - 我想要偏移 标记
从默认位置向右移动约 80px。
I have changed the image that I use for a marker
on Google maps. The new image is much wider than the old one and I have noticed that the marker is aligned with the lat
and lng
so that the marker rests with it's horizontal midpoint over the lat
and lng
. This is not what I want, I want to have the lat
and lng
aligned with the markers left hand side - I want to offset the marker
from the default position by about 80px to the right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
您需要 MarkerImage 的“anchor”属性。请注意,在构造函数调用中,origin 属性位于锚点之前。如果您不使用精灵,则可以只发送 null 作为可选参数。
如果您的标记为 80x60,并且您希望锚点位于左侧中间,请按如下方式创建:
var markerImage = new google.maps.MarkerImage('customIcon.png', new google.maps.Size(80, 60), null, new google.maps.Point(0, 30));
另请参阅 Google 的示例。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
试穿一下尺寸。
Try this on for size.