Adapt styleFunction in geojson example
This commit is contained in:
+42
-44
@@ -17,50 +17,48 @@ goog.require('ol.style.Style');
|
|||||||
|
|
||||||
var image = ol.shape.renderCircle(5, null,
|
var image = ol.shape.renderCircle(5, null,
|
||||||
new ol.style.Stroke({color: 'red', width: 1}));
|
new ol.style.Stroke({color: 'red', width: 1}));
|
||||||
var styleFunction = function(feature) {
|
|
||||||
switch (feature.getGeometry().getType()) {
|
var styles = {
|
||||||
case 'Point':
|
'Point': [new ol.style.Style({
|
||||||
return new ol.style.Style({
|
image: image
|
||||||
image: image
|
})],
|
||||||
});
|
'LineString': [new ol.style.Style({
|
||||||
case 'Polygon':
|
stroke: new ol.style.Stroke({
|
||||||
return new ol.style.Style({
|
color: 'green',
|
||||||
stroke: new ol.style.Stroke({
|
width: 1
|
||||||
color: 'blue',
|
})
|
||||||
width: 3
|
})],
|
||||||
}),
|
'MultiLineString': [new ol.style.Style({
|
||||||
fill: new ol.style.Fill({
|
stroke: new ol.style.Stroke({
|
||||||
color: 'rgba(0, 0, 255, 0.1)'
|
color: 'green',
|
||||||
})
|
width: 1
|
||||||
});
|
})
|
||||||
case 'MultiLineString':
|
})],
|
||||||
return new ol.style.Style({
|
'MultiPoint': [new ol.style.Style({
|
||||||
stroke: new ol.style.Stroke({
|
image: image
|
||||||
color: 'green',
|
})],
|
||||||
width: 1
|
'MultiPolygon': [new ol.style.Style({
|
||||||
})
|
stroke: new ol.style.Stroke({
|
||||||
});
|
color: 'yellow',
|
||||||
case 'MultiPolygon':
|
width: 1
|
||||||
return new ol.style.Style({
|
}),
|
||||||
stroke: new ol.style.Stroke({
|
fill: new ol.style.Fill({
|
||||||
color: 'yellow',
|
color: 'rgba(255, 255, 0, 0.1)'
|
||||||
width: 1
|
})
|
||||||
}),
|
})],
|
||||||
fill: new ol.style.Fill({
|
'Polygon': [new ol.style.Style({
|
||||||
color: 'rgba(255, 255, 0, 0.1)'
|
stroke: new ol.style.Stroke({
|
||||||
})
|
color: 'blue',
|
||||||
});
|
width: 3
|
||||||
default:
|
}),
|
||||||
return new ol.style.Style({
|
fill: new ol.style.Fill({
|
||||||
stroke: new ol.style.Stroke({
|
color: 'rgba(0, 0, 255, 0.1)'
|
||||||
color: 'red',
|
})
|
||||||
width: 2
|
})]
|
||||||
}),
|
};
|
||||||
fill: new ol.style.Fill({
|
|
||||||
color: 'rgba(255, 0, 0, 0.1)'
|
var styleFunction = function(feature, resolution) {
|
||||||
})
|
return styles[feature.getGeometry().getType()];
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var vectorSource = new ol.source.Vector();
|
var vectorSource = new ol.source.Vector();
|
||||||
|
|||||||
Reference in New Issue
Block a user