为什么Google Maps标记图标无法调整大小?

时间:2018-11-20 17:37:48

标签: javascript angular google-maps

如之前在this问题中所公开的,我有一张100x100的图片,我需要将其尺寸调整为30x30,以便可以将其用作Google Maps中标记的自定义图标。问题是它不会调整图标大小,但会显示原始图像的一个角(大小为30x30)。

工具:Angular 7.0和TypeScript 3.1.1。

根据https://developers.google.com/maps/documentation/javascript/examples/icon-complexprevious question中的文档,到目前为止我所拥有的:

const icon = {
    url: 'assets/img/bus.png',
    // resizeTo: 40  // doesn't do anything 
    scaleSized: new google.maps.Size(30, 30)
    // origin: new google.maps.Point(0, 0),
    // anchor: new google.maps.Point(0, 32)
};


const marker = new google.maps.Marker({
    map: this.map,
    position: new google.maps.LatLng(Position.Latitude, Position.Longitude),
    animation: google.maps.Animation.DROP,
    draggable: false,
    icon: icon
});

结果: map-with-marker

(抱歉,该链接我还不能嵌入图片)

0 个答案:

没有答案