All selected features in panel
by Vladimir Vershinin
HTML
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/dist/ol.js"></script>
<script src="https://unpkg.com/[email protected]/lib/index.umd.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/lib/style.css">
<div id="app">
<div class="panel">
Selection
<ul>
<li v-for="feature in selectedFeatures" :key="feature.id">
Feature {{ feature.id }}
</li>
</ul>
</div>
<vl-map ref="map" data-projection="EPSG:4326">
<vl-view :zoom.sync="zoom" :center.sync="center"></vl-view>
<vl-layer-tile>
<vl-source-osm></vl-source-osm>
</vl-layer-tile>
<vl-layer-vector ref="featuresLayer">
<vl-source-vector :features="features"></vl-source-vector>
</vl-layer-vector>
<vl-interaction-select :features.sync="selectedFeatures" :condition="eventCondition.pointerMove"></vl-interaction-select>
</vl-map>
</div>
CSS
html, body, #app {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.panel {
position: absolute;
height: 100%;
width: 100px;
padding: 10px;
background: #fff;
z-index: 1;
}
JavaScript
// external loaded features
let features = [
{
"type": "Feature",
"id": 1,
"properties": {
"special": true,
},
"geometry": {
"type": "Point",
"coordinates": [
-30.761718749999996,
58.90464570302001
]
}
},
{
"type": "Feature",
"id": 2,
"properties": {
"special": true,
},
"geometry": {
"type": "Point",
"coordinates": [
36.73828124999999,
44.59046718130883
]
}
},
{
"type": "Feature",
"id": 3,
"properties": {
"special": false
},
"geometry": {
"type": "Point",
"coordinates": [
-23.37890625,
32.10118973232094
]
}
}
]
new Vue({
el: '#app',
computed: {
eventCondition () {
return ol.events.condition
},
},
methods: {
},
data () {
return {
zoom: 3,
center: [-10, 35],
features: features,
selectedFeatures: [],
}
},
})