Adding ModifyFeature interaction
This is a first draft. The way geometry changes are handled for now is a bit clumsy. Both updating the feature cache RTree and making the layer aware of feature and geometry changes could be handled in a smarter way if these changes would be made through the layer instead of directly on the geometry or feature.
This commit is contained in:
@@ -158,7 +158,7 @@ ol.layer.Vector = function(options) {
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.temp_ = false;
|
||||
this.temporary_ = false;
|
||||
|
||||
};
|
||||
goog.inherits(ol.layer.Vector, ol.layer.Layer);
|
||||
@@ -241,7 +241,7 @@ ol.layer.Vector.prototype.clear = function() {
|
||||
* @return {boolean} Whether this layer is temporary.
|
||||
*/
|
||||
ol.layer.Vector.prototype.getTemporary = function() {
|
||||
return this.temp_;
|
||||
return this.temporary_;
|
||||
};
|
||||
|
||||
|
||||
@@ -463,10 +463,30 @@ ol.layer.Vector.prototype.removeFeatures = function(features) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} temp Whether this layer is temporary.
|
||||
* @param {boolean} temporary Whether this layer is temporary.
|
||||
*/
|
||||
ol.layer.Vector.prototype.setTemporary = function(temp) {
|
||||
this.temp_ = temp;
|
||||
ol.layer.Vector.prototype.setTemporary = function(temporary) {
|
||||
this.temporary_ = temporary;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* TODO: This should go away - features should either fire events when changed,
|
||||
* or feature changes should be made through the layer.
|
||||
*
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
*/
|
||||
ol.layer.Vector.prototype.updateFeatures = function(features) {
|
||||
var extent = ol.extent.createEmpty();
|
||||
for (var i = features.length - 1; i >= 0; --i) {
|
||||
var feature = features[i];
|
||||
var geometry = feature.getGeometry();
|
||||
this.featureCache_.remove(feature);
|
||||
this.featureCache_.add(feature);
|
||||
ol.extent.extend(extent, geometry.getBounds());
|
||||
}
|
||||
this.dispatchEvent(new ol.layer.VectorEvent(
|
||||
ol.layer.VectorLayerEventType.CHANGE, features, [extent]));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user