Set geometry to null if no geometry given

This commit is contained in:
Tom Payne
2013-12-07 19:51:54 +01:00
parent 1ae13f152d
commit 554e17ac22
2 changed files with 4 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ ol.Feature = function(opt_geometryOrValues) {
this, ol.Object.getChangeEventType(ol.FeatureProperty.GEOMETRY),
this.handleGeometryChanged_, false, this);
if (goog.isDef(opt_geometryOrValues)) {
if (goog.isDefAndNotNull(opt_geometryOrValues)) {
if (opt_geometryOrValues instanceof ol.geom.Geometry) {
var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrValues);
this.setGeometry(geometry);
@@ -57,6 +57,8 @@ ol.Feature = function(opt_geometryOrValues) {
var values = /** @type {Object.<string, *>} */ (opt_geometryOrValues);
this.setValues(values);
}
} else {
this.setGeometry(null);
}
};
goog.inherits(ol.Feature, ol.Object);

View File

@@ -251,8 +251,8 @@ ol.geom.Geometry.prototype.setLayout =
ol.geom.Geometry.prototype.transform = function(transformFn) {
if (!goog.isNull(this.flatCoordinates)) {
transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);
this.dispatchChangeEvent();
}
this.dispatchChangeEvent();
};