diff --git a/lib/OpenLayers/Format/GeoJSON.js b/lib/OpenLayers/Format/GeoJSON.js index b2631a02a8..a91c374c6f 100644 --- a/lib/OpenLayers/Format/GeoJSON.js +++ b/lib/OpenLayers/Format/GeoJSON.js @@ -204,6 +204,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { * {} A geometry. */ parseGeometry: function(obj) { + if (obj == null) { + return null; + } var geometry; if(obj.type == "GeometryCollection") { if(!(obj.geometries instanceof Array)) { @@ -532,6 +535,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { * {Object} An object representing the geometry. */ 'geometry': function(geometry) { + if (geometry == null) { + return null; + } if (this.internalProjection && this.externalProjection) { geometry = geometry.clone(); geometry.transform(this.internalProjection, diff --git a/tests/Format/GeoJSON.html b/tests/Format/GeoJSON.html index 8b05fb2e9c..c93690d5f8 100644 --- a/tests/Format/GeoJSON.html +++ b/tests/Format/GeoJSON.html @@ -4,6 +4,7 @@