Skip to content

Commit 2a38a80

Browse files
committed
Allow null GeoJSON geometries.
This change checks if a geometry/ies in GeoJSON are set as null, in which case it will skip it.
1 parent a9c12f1 commit 2a38a80

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/layer/GeoJSON.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ L.GeoJSON = L.FeatureGroup.extend({
2020

2121
if (features) {
2222
for (i = 0, len = features.length; i < len; i++) {
23-
this.addData(features[i]);
23+
// Only add this if geometry or geometries are set and not null
24+
if ((typeof features[i].geometries !== undefined && features[i].geometries !== null) &&
25+
(typeof features[i].geometry !== undefined && features[i].geometry !== null)) {
26+
27+
this.addData(features[i]);
28+
29+
}
2430
}
2531
return this;
2632
}

0 commit comments

Comments
 (0)