GoogleMaps-具有多种颜色的多个标记 [英] GoogleMaps - multiple markers with multiple colors
问题描述
我正在尝试制作带有一些标记的漂亮的Google地图.我在网络上找到了一些非常方便的解决方案,几乎可以满足我的所有需求:D我想给地图上的图钉/标记着色.
I'm trying to make a nice google map with some markers on it. I've found some really convinient solution in the web, which covers almost my every need :D I'd like to colorize pin/markers on the map.
好吧,试图制作一个可工作的jsfiddle,但不幸的是,出了点问题:(所以您看不到地图,但是有所有代码:) http://jsfiddle.net/hf37ftra/9/
Well, tried to make a working jsfiddle, but unfortunately, something went wrong :( so you wouldn't see the map, but there are all codes :) http://jsfiddle.net/hf37ftra/9/
// Multiple Markers
var markers = [
['Marker_name', 51.113882,17.070474],
];
这部分负责显示多个标记,我可以在这里以某种方式定义标记的颜色(我知道有可能,因为我找到了可以更改所有标记颜色的教程,但我想让我们说4-5个不同的彩色标记)?
this part is responsible for showing multiple markers, can I somehow define here the color of the marker (I know it is possible, because I've found tutorials to change ALL the markers colors, but I'd like to make let's say 4-5 different coloured markers)?
代码中的每个部分都是每个标记的自定义信息框的一部分,因此也许可以这样:)谢谢!
Later in the code is part for custom info box for every marker, so maybe it could be done that way :) thanks!
推荐答案
您可以使用类似:
var markers = [
['Starter', 51.113882,17.070474,'icon1.png'],
];
并将您的构造函数更改为:
and change your constructor to :
[...]
marker = new google.maps.Marker({
position: position,
map: map,
title: markers[i][0],
icon: markers[i][3]
});
这篇关于GoogleMaps-具有多种颜色的多个标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!