Update property change listener
This commit is contained in:
@@ -209,6 +209,12 @@ ol.Feature.prototype.setId = function(id) {
|
|||||||
* @param {string} name Geometry property name.
|
* @param {string} name Geometry property name.
|
||||||
*/
|
*/
|
||||||
ol.Feature.prototype.setGeometryName = function(name) {
|
ol.Feature.prototype.setGeometryName = function(name) {
|
||||||
|
goog.events.unlisten(
|
||||||
|
this, ol.Object.getChangeEventType(this.geometryName_),
|
||||||
|
this.handleGeometryChanged_, false, this);
|
||||||
this.geometryName_ = name;
|
this.geometryName_ = name;
|
||||||
|
goog.events.listen(
|
||||||
|
this, ol.Object.getChangeEventType(this.geometryName_),
|
||||||
|
this.handleGeometryChanged_, false, this);
|
||||||
this.handleGeometryChanged_();
|
this.handleGeometryChanged_();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -185,6 +185,24 @@ describe('ol.Feature', function() {
|
|||||||
expect(feature.getGeometry()).to.be(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
feature.setGeometryName('altGeometry');
|
feature.setGeometryName('altGeometry');
|
||||||
expect(feature.getGeometry()).to.be(point2);
|
expect(feature.getGeometry()).to.be(point2);
|
||||||
|
|
||||||
|
feature.on('change', function() {
|
||||||
|
expect.fail();
|
||||||
|
});
|
||||||
|
point.setCoordinates([0, 2]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('changes property listener', function(done) {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.setGeometry(point);
|
||||||
|
var point2 = new ol.geom.Point([1, 2]);
|
||||||
|
feature.set('altGeometry', point2);
|
||||||
|
feature.setGeometryName('altGeometry');
|
||||||
|
|
||||||
|
feature.on('change', function() {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
point2.setCoordinates([0, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user