如何更改标记颜色?谷歌地图 [英] How to change marker color? Google Maps
问题描述
function createMarker(latlng, item) {
var marker = new google.maps.Marker({
position: latlng,
map: map
});
这部分代码.它在网站上显示为标准标记,除了红色外,它适合我们所有人.如何将其更改为另一种颜色?
This part of the code . On the website it appears as a standard marker, it suits us all but red. How do I change it to another color?
https://yadi.sk/i/ZDONpfoijAjdZ
推荐答案
You should use the icon
property. For example,
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
There are many colors available at google.com. Just replace green-dot
with your color, like:
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
(要获取图像URL,将其悬停在其上,或右键单击→ 复制图像位置" 等)
(to get image URL, hover over it or Right-click → 'Copy Image Location' etc)
更多信息,请访问: https://sites.google.com/site/gmapsdevelopment/或搜索更多.
More at: https://sites.google.com/site/gmapsdevelopment/ or search for more.
这篇关于如何更改标记颜色?谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!