diff --git a/src/ol/format/geojsonformat.js b/src/ol/format/geojsonformat.js index 098cb7fffd..0ca12944f1 100644 --- a/src/ol/format/geojsonformat.js +++ b/src/ol/format/geojsonformat.js @@ -508,7 +508,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function( ol.format.GeoJSON.writeGeometry_(geometry, opt_options)); } var properties = feature.getProperties(); - goog.object.remove(properties, 'geometry'); + goog.object.remove(properties, feature.getGeometryName()); if (!goog.object.isEmpty(properties)) { goog.object.set(object, 'properties', properties); } diff --git a/test/spec/ol/format/geojsonformat.test.js b/test/spec/ol/format/geojsonformat.test.js index a3da003c8f..370523d575 100644 --- a/test/spec/ol/format/geojsonformat.test.js +++ b/test/spec/ol/format/geojsonformat.test.js @@ -498,6 +498,15 @@ describe('ol.format.GeoJSON', function() { } }); + it('writes out a feature with a different geometryName correctly', + function() { + var feature = new ol.Feature({'foo': 'bar'}); + feature.setGeometryName('mygeom'); + feature.setGeometry(new ol.geom.Point([5, 10])); + var geojson = format.writeFeatures([feature]); + expect(geojson.features[0].properties.mygeom).to.eql(undefined); + }); + }); describe('#writeGeometry', function() {