在经度和纬度上方移动自定义的谷歌地图标记

时间:2014-06-10 09:13:39

标签: javascript google-maps

请告诉我如何在纬度和经度点以上移动自定义谷歌地图标记?

这是JSBIN:Link,这里我使用了三个对象数组,只是用这个链接来低估编码结构,

请让我知道我必须在哪里插入"锚定#34;定位自定义图标?

1 个答案:

答案 0 :(得分:0)

您可以使用icon objectanchor属性,并添加标记图像所需的任何偏移量。

var iconObj = {
    url: '/path/to/icon.png', //path to icon image
    origin: new google.maps.Point(0, 0), //position of the image within a sprite
    anchor: new google.maps.Point(25, 25), //position at which to anchor an icon in correspondance to the position of the marker
};

var markerObj = new google.maps.Marker({
    position: point, 
    map: map, 
    icon: iconObj
});

<强>更新

要回答你的第二个问题'我在哪里将其完全放在我的代码中' - 你应该将icon作为对象放在drivers数组而不是字符串中。

这是modified working version of your code

相关问题