Don't render feature with all countries
The feature with undefined id is a multi-polygon representing all countries. Instead of rendering all multi-polygons with a lower z-index, we just avoid rendering this single feature.
This commit is contained in:
@@ -15,13 +15,6 @@ var raster = new ol.layer.Tile({
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: new ol.source.TopoJSON({
|
||||
projection: 'EPSG:3857',
|
||||
url: 'data/topojson/world-110m.json'
|
||||
}),
|
||||
styleFunction: function(feature, resolution) {
|
||||
var styleArray = [new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.6)'
|
||||
@@ -29,10 +22,17 @@ var vector = new ol.layer.Vector({
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#319FD3',
|
||||
width: 1
|
||||
}),
|
||||
zIndex: (feature.getGeometry().getType() !== 'MultiPolygon') ? 2 : 1
|
||||
})
|
||||
})];
|
||||
return styleArray;
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: new ol.source.TopoJSON({
|
||||
projection: 'EPSG:3857',
|
||||
url: 'data/topojson/world-110m.json'
|
||||
}),
|
||||
styleFunction: function(feature, resolution) {
|
||||
// don't want to render the full world polygon, which repeats all countries
|
||||
return feature.getId() !== undefined ? styleArray : null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user