Javascript,更改谷歌地图标记颜色 [英] Javascript, Change google map marker color

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

问题描述

我是否可以知道一种通过 Javascript 更改 Google 地图标记颜色的方法.我是新手,非常感谢您的帮助.

May I know a way to change the Google Map marker color via Javascript.. I am new at this and any help would be much appreciated, Thank you.

我使用以下代码创建了一个标记

I used the following code to create a marker

 marker = new google.maps.Marker({
     position: new google.maps.LatLng(locations[i][1], 
     locations[i][2]),
     animation: google.maps.Animation.DROP,
     map: map
 });

推荐答案

在 Google Maps API v3 中,您可以尝试更改标记图标.例如绿色图标使用:

In Google Maps API v3 you can try changing marker icon. For example for green icon use:

marker.setIcon('http://maps.google.com/mapfiles/ms/icons/green-dot.png')

或者作为标记初始化的一部分:

Or as part of marker init:

marker = new google.maps.Marker({
    icon: 'http://...'
});

其他颜色:

这篇关于Javascript,更改谷歌地图标记颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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