From c43e72da168324e770e331c4fdab06af6396d856 Mon Sep 17 00:00:00 2001 From: snkashis Date: Sun, 20 Jan 2013 19:13:43 -0500 Subject: [PATCH 1/7] Handle arrays of feature collections --- src/layer/GeoJSON.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index 0d618a75..92d53798 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -15,13 +15,15 @@ L.GeoJSON = L.FeatureGroup.extend({ }, addData: function (geojson) { - var features = L.Util.isArray(geojson) ? geojson : geojson.features, + var features = L.Util.isArray(geojson) ? geojson : geojson.features, i, len; if (features) { for (i = 0, len = features.length; i < len; i++) { // Only add this if geometry or geometries are set and not null - if (features[i].geometries || features[i].geometry) { + if (features[i].type === 'FeatureCollection') { + this.addData(features[i].features); + } else if (features[i].geometries || features[i].geometry) { this.addData(features[i]); } } From 52b445a36dd3704c8ddca786ff02892deabf439c Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 20 Jan 2013 19:35:18 -0500 Subject: [PATCH 2/7] Simplify features check --- src/layer/GeoJSON.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index 92d53798..dfa4a18c 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -21,7 +21,7 @@ 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 (features[i].type === 'FeatureCollection') { + if (features[i].features) { this.addData(features[i].features); } else if (features[i].geometries || features[i].geometry) { this.addData(features[i]); From 03a775c69b046ac921611f1e51ad3c12d8051028 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 20 Jan 2013 19:38:12 -0500 Subject: [PATCH 3/7] Trying to fix whitespace --- src/layer/GeoJSON.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index dfa4a18c..df72b1e2 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -17,7 +17,7 @@ L.GeoJSON = L.FeatureGroup.extend({ addData: function (geojson) { var features = L.Util.isArray(geojson) ? geojson : geojson.features, i, len; - + if (features) { for (i = 0, len = features.length; i < len; i++) { // Only add this if geometry or geometries are set and not null From c0210009dfcb964a140d57226cd26d5cbca878e3 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 20 Jan 2013 19:39:01 -0500 Subject: [PATCH 4/7] whitespace again --- src/layer/GeoJSON.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index df72b1e2..dfa4a18c 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -17,7 +17,7 @@ L.GeoJSON = L.FeatureGroup.extend({ addData: function (geojson) { var features = L.Util.isArray(geojson) ? geojson : geojson.features, i, len; - + if (features) { for (i = 0, len = features.length; i < len; i++) { // Only add this if geometry or geometries are set and not null From 9856a66864f115297a21b42e50e31da7da9cc065 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 20 Jan 2013 20:06:52 -0500 Subject: [PATCH 5/7] whitespace fix? --- src/layer/GeoJSON.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index dfa4a18c..df72b1e2 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -17,7 +17,7 @@ L.GeoJSON = L.FeatureGroup.extend({ addData: function (geojson) { var features = L.Util.isArray(geojson) ? geojson : geojson.features, i, len; - + if (features) { for (i = 0, len = features.length; i < len; i++) { // Only add this if geometry or geometries are set and not null From 65aad9929713d93750eb4655fb8af814f5225768 Mon Sep 17 00:00:00 2001 From: snkashis Date: Sun, 20 Jan 2013 20:18:48 -0500 Subject: [PATCH 6/7] Revert "whitespace fix?" This reverts commit 9856a66864f115297a21b42e50e31da7da9cc065. --- src/layer/GeoJSON.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index df72b1e2..dfa4a18c 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -17,7 +17,7 @@ L.GeoJSON = L.FeatureGroup.extend({ addData: function (geojson) { var features = L.Util.isArray(geojson) ? geojson : geojson.features, i, len; - + if (features) { for (i = 0, len = features.length; i < len; i++) { // Only add this if geometry or geometries are set and not null From 5524db2816df823baf9150e4a4a1034c5d0cb123 Mon Sep 17 00:00:00 2001 From: snkashis Date: Mon, 21 Jan 2013 10:14:42 -0500 Subject: [PATCH 7/7] condition on one line --- src/layer/GeoJSON.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index dfa4a18c..0a154a7e 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -21,9 +21,7 @@ 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 (features[i].features) { - this.addData(features[i].features); - } else if (features[i].geometries || features[i].geometry) { + if (features[i].geometries || features[i].geometry || features[i].features) { this.addData(features[i]); } }