Render style for Point inside GeometryCollection.

This commit is contained in:
Antoine Abt
2014-02-06 15:27:43 +01:00
parent 72675bf6ad
commit c95ffe381b

View File

@@ -26,7 +26,7 @@ var raster = new ol.layer.Tile({
var image = new ol.style.Circle({ var image = new ol.style.Circle({
radius: 5, radius: 5,
fill: null, fill: null,
stroke: new ol.style.Stroke({color: 'red', width: 1}) stroke: new ol.style.Stroke({color: 'orange', width: 2})
}); });
var styleFunction = function(feature) { var styleFunction = function(feature) {
@@ -49,7 +49,7 @@ var styleFunction = function(feature) {
return [new ol.style.Style({ return [new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: 'green', color: 'green',
width: 1 width: 3
}) })
})]; })];
case 'MultiPolygon': case 'MultiPolygon':
@@ -66,11 +66,12 @@ var styleFunction = function(feature) {
return [new ol.style.Style({ return [new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: 'red', color: 'red',
width: 2 width: 3
}), }),
fill: new ol.style.Fill({ fill: new ol.style.Fill({
color: 'rgba(255, 0, 0, 0.1)' color: 'rgba(255, 0, 0, 0.1)'
}) }),
image: image
})]; })];
} }
}; };
@@ -188,8 +189,6 @@ var overlayStyle = (function() {
]; ];
styles[ol.geom.GeometryType.MULTI_POLYGON] = styles[ol.geom.GeometryType.MULTI_POLYGON] =
styles[ol.geom.GeometryType.POLYGON]; styles[ol.geom.GeometryType.POLYGON];
styles[ol.geom.GeometryType.GEOMETRY_COLLECTION] =
styles[ol.geom.GeometryType.POLYGON];
styles[ol.geom.GeometryType.LINE_STRING] = [ styles[ol.geom.GeometryType.LINE_STRING] = [
new ol.style.Style({ new ol.style.Style({
@@ -226,6 +225,10 @@ var overlayStyle = (function() {
styles[ol.geom.GeometryType.MULTI_POINT] = styles[ol.geom.GeometryType.MULTI_POINT] =
styles[ol.geom.GeometryType.POINT]; styles[ol.geom.GeometryType.POINT];
styles[ol.geom.GeometryType.GEOMETRY_COLLECTION] =
styles[ol.geom.GeometryType.POLYGON].concat(
styles[ol.geom.GeometryType.POINT]);
return function(feature, resolution) { return function(feature, resolution) {
return styles[feature.getGeometry().getType()]; return styles[feature.getGeometry().getType()];
}; };