Set the 'properties' member to null if the feature has not properties
This commit is contained in:
@@ -516,6 +516,8 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(
|
|||||||
goog.object.remove(properties, feature.getGeometryName());
|
goog.object.remove(properties, feature.getGeometryName());
|
||||||
if (!goog.object.isEmpty(properties)) {
|
if (!goog.object.isEmpty(properties)) {
|
||||||
object['properties'] = properties;
|
object['properties'] = properties;
|
||||||
|
} else {
|
||||||
|
object['properties'] = null;
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -507,6 +507,12 @@ describe('ol.format.GeoJSON', function() {
|
|||||||
expect(geojson.features[0].properties.mygeom).to.eql(undefined);
|
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() {
|
describe('#writeGeometry', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user