gpt4 book ai didi

google-maps-markers - 如何更改标记颜色?谷歌地图

转载 作者:行者123 更新时间:2023-12-02 18:05:49 31 4
gpt4 key购买 nike

function createMarker(latlng, item) {
var marker = new google.maps.Marker({
position: latlng,
map: map
});

这部分代码。在网站上,它显示为标准标记,它适合我们所有人,但红色除外。如何将其更改为其他颜色?

https://yadi.sk/i/ZDONpfoijAjdZ

最佳答案

您应该使用icon属性(property)。例如,

var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
});

google.com 上有多种颜色可供选择。只需将 green-dot 替换为您的颜色,例如:
http://maps.google.com/mapfiles/ms/icons/green-dot.png
http://maps.google.com/mapfiles/ms/icons/blue-dot.png
http://maps.google.com/mapfiles/ms/icons/red-dot.png
http://maps.google.com/mapfiles/ms/icons/yellow-dot.png

<小时/>

来自 Google 的一些示例:

(要获取图像 URL,请将鼠标悬停在其上或右键单击 →“复制图像位置” 等)

64×64px

32×32px

12×20px

更多信息:https://sites.google.com/site/gmapsdevelopment/search了解更多。

关于google-maps-markers - 如何更改标记颜色?谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32651238/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com