谷歌地图API:标记图像定位 [英] Google maps API: Marker image positioning

查看:32
本文介绍了谷歌地图API:标记图像定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更改了用于 Google 地图上marker 的图像.新图像比旧图像宽得多,我注意到标记与 latlng 对齐,因此标记位于 latlng 的水平中点上方code>lat 和 lng.这不是我想要的,我想让 latlng 与标记左侧对齐 - 我想偏移 marker从默认位置向右约 80 像素.

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.

推荐答案

试试这个尺寸.

var markerImage = new google.maps.MarkerImage('/img/icon/here.png',
    new google.maps.Size(80, 80), //size
    new google.maps.Point(0, 0), //origin point
    new google.maps.Point(0, 80)); // offset point
marker[stamp] = new google.maps.Marker({
    position: loc, // loc is a variable with my lngLat object
    title: params.name,
    map: window.gMaps[params.map],
    icon: markerImage
});

这篇关于谷歌地图API:标记图像定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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