如何更改标记颜色?谷歌地图 [英] How to change marker color? Google Maps

查看:206
本文介绍了如何更改标记颜色?谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆