diff --git a/lib/OpenLayers/Format/GeoJSON.js b/lib/OpenLayers/Format/GeoJSON.js index 9ca6f29509..8e9f49a855 100644 --- a/lib/OpenLayers/Format/GeoJSON.js +++ b/lib/OpenLayers/Format/GeoJSON.js @@ -530,12 +530,15 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { */ 'feature': function(feature) { var geom = this.extract.geometry.apply(this, [feature.geometry]); - return { + var json = { "type": "Feature", - "id": feature.fid == null ? feature.id : feature.fid, "properties": feature.attributes, "geometry": geom }; + if (feature.fid != null) { + json.id = feature.fid; + } + return json; }, /** diff --git a/tests/Format/GeoJSON.html b/tests/Format/GeoJSON.html index 03f00377a0..98e950f795 100644 --- a/tests/Format/GeoJSON.html +++ b/tests/Format/GeoJSON.html @@ -4,7 +4,7 @@