Make select interaction create its FeatureOverlay
You can now configure it with a `style` option.
This commit is contained in:
@@ -227,12 +227,15 @@ var overlayStyle = (function() {
|
||||
};
|
||||
})();
|
||||
|
||||
var select = new ol.interaction.Select({
|
||||
style: overlayStyle
|
||||
});
|
||||
var overlay = new ol.FeatureOverlay({
|
||||
features: select.getFeatures(),
|
||||
style: overlayStyle
|
||||
});
|
||||
|
||||
var modify = new ol.interaction.Modify({ featureOverlay: overlay });
|
||||
var select = new ol.interaction.Select({ featureOverlay: overlay });
|
||||
|
||||
var map = new ol.Map({
|
||||
interactions: ol.interaction.defaults().extend([select, modify]),
|
||||
|
||||
@@ -31,11 +31,9 @@ var vector = new ol.layer.Vector({
|
||||
});
|
||||
|
||||
var select = new ol.interaction.Select({
|
||||
featureOverlay: new ol.FeatureOverlay({
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255,255,255,0.5)'
|
||||
})
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255,255,255,0.5)'
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
@@ -440,7 +440,7 @@
|
||||
* features should be selected.
|
||||
* @property {Array.<ol.layer.Layer>|undefined} layers Layers. Zero or more
|
||||
* layers from which features should be selected.
|
||||
* @property {ol.FeatureOverlay} featureOverlay Feature overlay.
|
||||
* @property {ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined} style FeatureOverlay style.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
@exportSymbol ol.interaction.Select
|
||||
@exportProperty ol.interaction.Select.prototype.getFeatureOverlay
|
||||
@exportProperty ol.interaction.Select.prototype.getFeatures
|
||||
@exportProperty ol.interaction.Select.prototype.setMap
|
||||
|
||||
@@ -69,18 +69,20 @@ ol.interaction.Select = function(options) {
|
||||
* @private
|
||||
* @type {ol.FeatureOverlay}
|
||||
*/
|
||||
this.featureOverlay_ = options.featureOverlay;
|
||||
this.featureOverlay_ = new ol.FeatureOverlay({
|
||||
style: options.style
|
||||
});
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.Select, ol.interaction.Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.FeatureOverlay} Feature overlay.
|
||||
* @return {ol.Collection} Features collection.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.interaction.Select.prototype.getFeatureOverlay = function() {
|
||||
return this.featureOverlay_;
|
||||
ol.interaction.Select.prototype.getFeatures = function() {
|
||||
return this.featureOverlay_.getFeatures();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user