From d288c5b4eb2173fb21cbfc6fcfaa5ff7b61a7e06 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 7 Feb 2014 10:31:02 -0700 Subject: [PATCH] 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. --- examples/topojson.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/topojson.js b/examples/topojson.js index 9a60037a5a..0cdde09c0c 100644 --- a/examples/topojson.js +++ b/examples/topojson.js @@ -15,6 +15,15 @@ var raster = new ol.layer.Tile({ }) }); +var styleArray = [new ol.style.Style({ + fill: new ol.style.Fill({ + color: 'rgba(255, 255, 255, 0.6)' + }), + stroke: new ol.style.Stroke({ + color: '#319FD3', + width: 1 + }) +})]; var vector = new ol.layer.Vector({ source: new ol.source.TopoJSON({ @@ -22,17 +31,8 @@ var vector = new ol.layer.Vector({ 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)' - }), - stroke: new ol.style.Stroke({ - color: '#319FD3', - width: 1 - }), - zIndex: (feature.getGeometry().getType() !== 'MultiPolygon') ? 2 : 1 - })]; - return styleArray; + // don't want to render the full world polygon, which repeats all countries + return feature.getId() !== undefined ? styleArray : null; } });