【问题标题】:Custom marker icon in Google maps pops up before animation谷歌地图中的自定义标记图标在动画之前弹出
【发布时间】:2013-01-31 07:09:13
【问题描述】:

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

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

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

【问题讨论】:

标签: google-maps-api-3 google-maps-markers


【解决方案1】:

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

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
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-24
    • 2015-06-06
    • 2018-01-13
    • 2013-08-21
    • 1970-01-01
    相关资源
    最近更新 更多