3

我有以下代码向我的地图添加标记:

var marker = new google.maps.Marker({
    icon: '/pin.png',
    map: map,
    position: latlng,
    draggable: false,
    title: trip_name,
    animation: google.maps.Animation.DROP
});

一切正常,除了图标在运行动画之前弹出一秒钟。有没有其他人遇到过这个问题?

4

1 回答 1

4

我遇到了同样的行为,我发现进一步定义自定义图标有助于解决这个问题。

var image = {
    url: 'images/map_marker.png',
    // This marker is 20 pixels wide by 30 pixels tall.
    size: new google.maps.Size(20, 30),
    // The origin for this image is 0,0.
    origin: new google.maps.Point(0,0),
    // The anchor for this image is the base of the image at 0,30.
    anchor: new google.maps.Point(10, 30)
};

var marker = new google.maps.Marker({
   icon: image,
   map: map,
   position: latlng,
   draggable: false,
   title: trip_name,
   animation: google.maps.Animation.DROP
});
于 2013-05-02T15:55:43.130 回答