【发布时间】:2018-09-07 08:56:19
【问题描述】:
所以,我正在尝试更改传单地图中标记群集图标的颜色。我只想更改继承其余默认属性(即形状、文本属性等)的颜色。
在example 中,有一些类似于我想要得到的东西,但它们定义了一个全新的 CSS 类,而不使用默认图标样式。我需要的是这样的东西,但有自定义颜色:
我知道我必须自定义iconCreateFunction。我正在尝试这种方式:
CSS
.foo { background-color: red;}
.bar { background-color: blue;}
JavaScript
var markers = L.markerClusterGroup({
iconCreateFunction: function(cluster) {
// here there is a piece code that determines the value of the variable 'class_name' is either foo or bar
return L.divIcon({ className: "marker-cluster-medium "+class_name});
}
});
不幸的是,该解决方案不起作用并导致图标呈现丑陋。
我怎样才能改变默认markercluster图标的颜色?
【问题讨论】:
标签: javascript css leaflet markerclusterer