From 2a38a809d36e7069a03cd799e4f0a4b263deb2f7 Mon Sep 17 00:00:00 2001 From: Brian Herbert Date: Thu, 27 Dec 2012 12:15:08 +0900 Subject: [PATCH 1/2] Allow null GeoJSON geometries. This change checks if a geometry/ies in GeoJSON are set as null, in which case it will skip it. --- src/layer/GeoJSON.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index 99fef988..3b71b55f 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -20,7 +20,13 @@ L.GeoJSON = L.FeatureGroup.extend({ if (features) { for (i = 0, len = features.length; i < len; i++) { - this.addData(features[i]); + // Only add this if geometry or geometries are set and not null + if ((typeof features[i].geometries !== undefined && features[i].geometries !== null) && + (typeof features[i].geometry !== undefined && features[i].geometry !== null)) { + + this.addData(features[i]); + + } } return this; } From 971e55b91152dc70b6db7e03a695cb74ffa84629 Mon Sep 17 00:00:00 2001 From: Brian Herbert Date: Fri, 28 Dec 2012 11:56:19 +0900 Subject: [PATCH 2/2] Simplifying condition for null geojson geometries. Used feedback from @mourner to make the change from the pull request #1240 --- src/layer/GeoJSON.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index 3b71b55f..6b403a02 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -21,11 +21,8 @@ L.GeoJSON = L.FeatureGroup.extend({ if (features) { for (i = 0, len = features.length; i < len; i++) { // Only add this if geometry or geometries are set and not null - if ((typeof features[i].geometries !== undefined && features[i].geometries !== null) && - (typeof features[i].geometry !== undefined && features[i].geometry !== null)) { - + if (features[i].geometries || features[i].geometry) { this.addData(features[i]); - } } return this;