Add getOverlay method to access sketch and selection layers
This commit is contained in:
@@ -441,6 +441,15 @@ class Draw extends PointerInteraction {
|
|||||||
this.updateState_();
|
this.updateState_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the overlay layer that this interaction renders sketch features to.
|
||||||
|
* @return {module:ol/layer/Vector} Overlay layer.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
getOverlay() {
|
||||||
|
return this.overlay_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle move events.
|
* Handle move events.
|
||||||
* @param {module:ol/MapBrowserEvent} event A move event.
|
* @param {module:ol/MapBrowserEvent} event A move event.
|
||||||
|
|||||||
@@ -422,6 +422,15 @@ class Modify extends PointerInteraction {
|
|||||||
super.setMap(map);
|
super.setMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the overlay layer that this interaction renders sketch features to.
|
||||||
|
* @return {module:ol/layer/Vector} Overlay layer.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
getOverlay() {
|
||||||
|
return this.overlay_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {module:ol/source/Vector~VectorSourceEvent} event Event.
|
* @param {module:ol/source/Vector~VectorSourceEvent} event Event.
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -255,11 +255,13 @@ class Select extends Interaction {
|
|||||||
*/
|
*/
|
||||||
this.featureLayerAssociation_ = {};
|
this.featureLayerAssociation_ = {};
|
||||||
|
|
||||||
const features = this.featureOverlay_.getSource().getFeaturesCollection();
|
if (this.featureOverlay_) {
|
||||||
listen(features, CollectionEventType.ADD,
|
const features = this.featureOverlay_.getSource().getFeaturesCollection();
|
||||||
this.addFeature_, this);
|
listen(features, CollectionEventType.ADD,
|
||||||
listen(features, CollectionEventType.REMOVE,
|
this.addFeature_, this);
|
||||||
this.removeFeature_, this);
|
listen(features, CollectionEventType.REMOVE,
|
||||||
|
this.removeFeature_, this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +309,15 @@ class Select extends Interaction {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the overlay layer that this interaction renders selected features to.
|
||||||
|
* @return {module:ol/layer/Vector} Overlay layer.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
getOverlay() {
|
||||||
|
return this.featureOverlay_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hit-detection tolerance. Pixels inside the radius around the given position
|
* Hit-detection tolerance. Pixels inside the radius around the given position
|
||||||
* will be checked for features. This only works for the canvas renderer and
|
* will be checked for features. This only works for the canvas renderer and
|
||||||
|
|||||||
@@ -1060,6 +1060,13 @@ describe('ol.interaction.Draw', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getOverlay', function() {
|
||||||
|
it('returns the feature overlay layer', function() {
|
||||||
|
const draw = new Draw({});
|
||||||
|
expect (draw.getOverlay()).to.eql(draw.overlay_);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('createRegularPolygon', function() {
|
describe('createRegularPolygon', function() {
|
||||||
it('creates a regular polygon in Circle mode', function() {
|
it('creates a regular polygon in Circle mode', function() {
|
||||||
const draw = new Draw({
|
const draw = new Draw({
|
||||||
|
|||||||
@@ -712,4 +712,13 @@ describe('ol.interaction.Modify', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getOverlay', function() {
|
||||||
|
it('returns the feature overlay layer', function() {
|
||||||
|
const modify = new Modify({
|
||||||
|
features: new Collection()
|
||||||
|
});
|
||||||
|
expect (modify.getOverlay()).to.eql(modify.overlay_);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -442,4 +442,11 @@ describe('ol.interaction.Select', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getOverlay', function() {
|
||||||
|
it('returns the feature overlay layer', function() {
|
||||||
|
const select = new Select();
|
||||||
|
expect (select.getOverlay()).to.eql(select.featureOverlay_);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user