MelihAltintas / vue3-openlayers

Web map Vue 3.x components with the power of OpenLayers

Home Page:https://vue3openlayers.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No addFeature/changefeature event is thrown

fbatschi opened this issue · comments

Describe the bug

When adding @addFeature to a ol-source-vector there should be events for whenever a feature is added to the ol-source-vector. Such an event is never thrown. Seems to be the case for other events as well, although the documentation states, that all events of OpenLayers are handled.

Affected version(s)

v10.0.1, did not test others

To Reproduce
Steps to reproduce the behavior:

  1. use this code
<template>
<ol-map
  ref="map"
  :loadTilesWhileAnimating="true"
  :loadTilesWhileInteracting="true"
  style="height: 400px"
  :controls="[]"
>
  <ol-view
    ref="view"
    :center="center"
    :zoom="zoom"
    :projection="projection"
  />
  <ol-tile-layer ref="osmLayer" title="OSM">
    <ol-source-osm />
  </ol-tile-layer>

  <ol-control-bar>
    <ol-toggle-control
      html="🔘"
      className="edit"
      title="Point"
      :onToggle="(active) => changeDrawType(active, 'Point')"
    />
  </ol-control-bar>

  <ol-source-vector @addFeature="handleAddFeature">
  <ol-interaction-draw
    :type="drawType"
    @drawend="drawend"
    @drawstart="drawstart"
  >
  </ol-interaction-draw>
</ol-source-vector>
</ol-map>
</template>

<script setup>
import { ref } from "vue";

const center = ref([34, 39.13]);
const projection = ref("EPSG:4326");
const zoom = ref(6);
const view = ref(null);

const drawEnable = ref(false);
const drawType = ref("Point");

const changeDrawType = (active, draw) => {
drawEnable.value = active;
drawType.value = draw;
};

const drawstart = (event) => {
console.log(event);
};

const drawend = (event) => {
console.log(event);
};

const handleAddFeature = (event) => {
  console.log(event);
}

const osmLayer = ref(null);
</script>
  1. Add a point
  2. There should be an event visible in the console, but it is not.

Expected behavior
adding

Additional context

According to

these features are defined as FEATURE_EVENTS

the problem might be, that the Openlayers event is actually addfeature and not addFeature ?