Removed SelectInteraction

This commit is contained in:
Simon Seyock
2019-09-23 14:54:46 +02:00
parent c65e802c71
commit 3838b68427
16 changed files with 289 additions and 1127 deletions
+35 -5
View File
@@ -2,9 +2,13 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
import GeoJSON from '../src/ol/format/GeoJSON.js';
import {DragBox, Select} from '../src/ol/interaction.js';
import {DragBox} from '../src/ol/interaction.js';
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
import Collection from '../src/ol/Collection.js';
import Style from '../src/ol/style/Style.js';
import Fill from '../src/ol/style/Fill.js';
import Stroke from '../src/ol/style/Stroke.js';
const vectorSource = new VectorSource({
@@ -30,11 +34,37 @@ const map = new Map({
})
});
// a normal select interaction to handle click
const select = new Select();
map.addInteraction(select);
const selectedFeatures = new Collection();
const selectedFeatures = select.getFeatures();
// style features in collection
const highlightStyle = new Style({
fill: new Fill({
color: 'rgba(255,255,255,0.7)'
}),
stroke: new Stroke({
color: '#3399CC',
width: 3
})
});
selectedFeatures.on('add', function(e) {
e.element.setStyle(highlightStyle);
});
selectedFeatures.on('remove', function(e) {
e.element.setStyle(undefined);
});
// handle clicks
map.on('singleclick', function(e) {
selectedFeatures.clear();
map.forEachFeatureAtPixel(e.pixel, function(f) {
selectedFeatures.push(f);
});
});
// a DragBox interaction used to select features by drawing boxes
const dragBox = new DragBox({