Merge pull request #3346 from fredj/geojson-feature-properties

Set the 'properties' member to null if the feature has not properties
This commit is contained in:
Frédéric Junod
2015-03-16 10:21:05 +01:00
2 changed files with 8 additions and 0 deletions

View File

@@ -516,6 +516,8 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(
goog.object.remove(properties, feature.getGeometryName());
if (!goog.object.isEmpty(properties)) {
object['properties'] = properties;
} else {
object['properties'] = null;
}
return object;
};

View File

@@ -507,6 +507,12 @@ describe('ol.format.GeoJSON', function() {
expect(geojson.features[0].properties.mygeom).to.eql(undefined);
});
it('writes out a feature without properties correctly', function() {
var feature = new ol.Feature(new ol.geom.Point([5, 10]));
var geojson = format.writeFeatureObject(feature);
expect(geojson.properties).to.eql(null);
});
});
describe('#writeGeometry', function() {