Adapt styleFunction in rtree example

This commit is contained in:
Éric Lemoine
2013-11-26 11:05:23 +01:00
parent 39af934e71
commit 82aa5cc675
+7 -7
View File
@@ -29,10 +29,10 @@ var vectorSource = new ol.source.Vector({
features: features features: features
}); });
var style = new ol.style.Style({ var styleArray = [new ol.style.Style({
image: ol.shape.renderCircle(3, null, image: ol.shape.renderCircle(3, null,
new ol.style.Stroke({color: 'red', width: 1})) new ol.style.Stroke({color: 'red', width: 1}))
}); })];
var colors = ['red', 'orange', 'yellow', 'blue', 'green', 'indigo', 'violet']; var colors = ['red', 'orange', 'yellow', 'blue', 'green', 'indigo', 'violet'];
var depthStyle = []; var depthStyle = [];
@@ -73,7 +73,7 @@ for (i = 0, ii = extentsByDepth.length; i < ii; ++i) {
]]); ]]);
var feature = new ol.Feature({ var feature = new ol.Feature({
'geometry': geometry, 'geometry': geometry,
'style': depthStyle[i] 'styleArray': [depthStyle[i]]
}); });
rtreeExtentFeatures.push(feature); rtreeExtentFeatures.push(feature);
} }
@@ -81,8 +81,8 @@ for (i = 0, ii = extentsByDepth.length; i < ii; ++i) {
var vector = new ol.layer.Vector({ var vector = new ol.layer.Vector({
source: vectorSource, source: vectorSource,
styleFunction: function(feature) { styleFunction: function(feature, resolution) {
return style; return styleArray;
} }
}); });
@@ -90,8 +90,8 @@ var rtree = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
features: rtreeExtentFeatures features: rtreeExtentFeatures
}), }),
styleFunction: function(feature) { styleFunction: function(feature, resolution) {
return feature.get('style'); return feature.get('styleArray');
} }
}); });