Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No addFeature/changefeature event is thrown #362

Closed
fbatschi opened this issue Jul 2, 2024 · 1 comment
Closed

No addFeature/changefeature event is thrown #362

fbatschi opened this issue Jul 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fbatschi
Copy link

fbatschi commented Jul 2, 2024

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

@fbatschi fbatschi added the bug Something isn't working label Jul 2, 2024
@fbatschi
Copy link
Author

fbatschi commented Jul 2, 2024

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant