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

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

问题描述

我可以通过Javascript知道改变Google Map标记颜色的方法吗?我是新来的,任何帮助都会非常感谢,谢谢。



我使用下面的代码来创建一个标记

  marker = new google.maps.Marker({
position:new google.maps.LatLng(位置[i] [1],
位置[i] [2]),
动画:google.maps.Animation.DROP,
地图:地图
});


解决方案

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

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

或作为marker的一部分init:

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

其他颜色:



等。

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
 });

解决方案

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://...'
});

Other colors:

Etc.

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

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