如何在Openlayers 3中將集羣層的樣式定義爲ol.style.Style
對象而不是函數?如何在沒有樣式函數的情況下動態設置集羣層的樣式
我正在使用僅接受ol.style.Style
對象進行造型的庫(ol3-google-maps)。該official cluster example使用樣式功能,在每個集羣特徵的數量動態地添加到它的圖標:
style: function(feature, resolution) {
console.log(feature);
var size = feature.get('features').length;
var style = styleCache[size];
if (!style) {
style = [
new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
stroke: new ol.style.Stroke({
color: '#fff'
}),
fill: new ol.style.Fill({
color: '#3399CC'
})
}),
text: new ol.style.Text({
text: size.toString(),
fill: new ol.style.Fill({
color: '#fff'
})
})
})
];
styleCache[size] = style;
}
return style;
}
請澄清一下您的問題。你想要什麼樣的物體?你指的是什麼圖書館? –
Hi Alvin, 在上面的代碼中,style屬性從函數(特徵,分辨率)中取值。我想直接創建ol.style.Style的一個對象,而不是使用該函數。 我正在使用mapgears庫來將谷歌地圖與ol3進行整合: - https://github.com/mapgears/ol3-google-maps 目前,圖書館沒有將功能作爲樣式屬性的值。 – user189107
我不認爲沒有樣式函數的集羣目前可以在ol3中使用。不過,我很樂意聽到更多關於此的信息。 –