Change point location of multiple custom marker icons Google Map API V3

邮差的信 提交于 2019-12-06 16:47:59

If you were using native Google Maps API v3 icons I would have said the below. Which is what your question asked.

However, on the map to which you provided a link (1), you are using a KMZ file for the Open House markers (2), are those the icons you are concerned about? To center those you need to add the hotSpot tag

(1)     http://url/

(2)     http://url/OpenHouse.kmz

<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction">

(which it looks like you have in at least some places)

=============================

If your icons are all 40px x 40px and need to be centered over the point. Look at the google.maps.Icon definition:

google.maps.Icon object specification
Properties | Type   | Description
anchor     | Point  | The position at which to anchor an image in correspondance to the     location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image.
origin     | Point  | The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image (0, 0).
scaledSize | Size   | The size of the entire image after scaling, if any. Use this property to stretch/shrink an image or a sprite.
size       | Size   | The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads.
url        | string | The URL of the image or sprite sheet.

You need:

var icon = { 
             url: 'your/URL/for the icon",
             size: new google.maps.Size(40,40),
             anchor: new google.maps.Point(20,20)
           };
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!