Interaction-select setter undefined

Interaction-select setter undefined

by Vladimir Vershinin

HTML

<script src="https://unpkg.com/[email protected]/lodash.js"></script>
<script src="https://unpkg.com/vue@latest/dist/vue.min.js"></script>
<script src="https://npmcdn.com/@turf/turf/turf.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/lib/style.css">
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io/en/v6.9.0/build/ol.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vuelayers.umd.js"></script>
<div id="app">
  <div>Current zoom {{ zoom }}</div>
  <vl-map ref="map" data-projection="EPSG:4326">
    <vl-view ref="mapView" :zoom.sync="zoom" :center.sync="center"></vl-view>
    
    <vl-layer-tile>
      <vl-source-osm />
    </vl-layer-tile>
    
    <!-- <vl-layer-vector id="points" render-mode="image">
      <vl-source-vector :features="points"></vl-source-vector>
      <vl-style-box>
        <vl-style-circle :radius="10">
          <vl-style-fill color="white"></vl-style-fill>
          <vl-style-stroke color="green"></vl-style-stroke>
        </vl-style-circle>
      </vl-style-box>
    </vl-layer-vector> -->
    
    <vl-layer-vector id="polygons" render-mode="image">
      <vl-source-vector :features="polygons"></vl-source-vector>
      <vl-style-box>
        <vl-style-fill color="white"></vl-style-fill>
        <vl-style-stroke color="green"></vl-style-stroke>
      </vl-style-box>
    </vl-layer-vector>
    <vl-interaction-select
            :active="true"
            source="polygons"
            @unselect="onDeselectFeature"
            @select="onSelectFeature"
            id='select-select'
        >
         <template slot-scope="selectScope">
    
                <vl-overlay
                    v-for="feature in selectScope.features"
                    :key="feature.id"
                    :id="feature.id"
                    positioning="center-left"
                    :autoPan="true"
                    :position="feature.geometry.coordinates[0][0]"
                ...

CSS

html, body, #app {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

JavaScript

new Vue({
	el: '#app',
  data () {
  	return {
    	zoom: 2,
      center: [0, 0],
      polygons: [
      	{
          type: 'Feature',
          id: 'square',
          geometry: {
            type: 'Polygon',
            coordinates: [
            	[
                [0, 0],
                [0, 20],
                [20, 20],
                [20, 0],
                [0, 0],
              ],
            ],
          },
          properties:{
    				styleObject: 'init'
    				}
        },
      ],
    }
  },
  methods:{
  	onDeselectFeature(evt){
    	console.log("Deselect feature properties =" );
      console.log(evt.feature.properties)
    },
    onSelectFeature(evt){
    	const inter = this.$refs.map.$interactionsCollection.getArray().find((item)=>item.get('id') === 'select-select');
      console.log('inter', inter)
      inter.setActive(false);
    },
    changeProperties(feature){
      feature.properties = {
        styleObject: 'futureStyle ' + new Date().getTime()
      }
   		console.log("binding feature properties=");
      console.log(feature.properties);
    }
  }
})