Google Maps v3自定义标记图标无法保持其在地图上的位置 [英] Google Maps v3 custom marker icon does not keep it's position on map
问题描述
使用Google Maps v3开发.
Developing with Google Maps v3.
出于某种原因,我的自定义标记图标更改"了其在放大时的位置.看起来它具有某种填充"属性,不会随缩放一起改变.
For some sort of reason, my custom marker icon "change" it's position on zoom in-out. It looks like it have some sort of "padding" property, that not changes together with zoom.
这表示在最大变焦(18)上它的位置是正确的,但是如果更改变焦值,它将移动"到顶部,并且在较小的变焦值上会出现问题,因为它看起来好像不在保持原样.
It means that it position is correct on maximum zoom (18), but if I change zoom value, it "moves" a bit to top, and it makes problem on smaller zoom values, because it looks like it is not on same position as it is.
标记定义为:
var image = new google.maps.MarkerImage('img/antennas/img.png',new google.maps.Size(100, 100));
这可能会有所帮助:标记图标是方形的100x100像素,它的中心位于图像的中间,而不是像正常"标记一样位于底部.
This maybe can help: marker icon is squared shape, 100x100px, and it's center is in middle of the image, not on the bottom like "normal" markers.
更新:我必须对锚属性进行某些处理吗?
UPDATE: do I have to do something with anchor property?
推荐答案
您必须设置标记的锚点.默认值为居中.
You have to set the anchor of the marker. The default is center bottom.
请参见 http://code.google.com/apis /maps/documentation/javascript/reference.html#MarkerImage
这篇关于Google Maps v3自定义标记图标无法保持其在地图上的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!