ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
681 stars 230 forks source link

When I draw feature drawnFeatures array doesn't change #396

Closed Nikitoring closed 3 years ago

Nikitoring commented 3 years ago

Example of my code https://codesandbox.io/s/drawendvuelayers-cflg9?file=/src/App.vue emit drawend doesn't change drawFeaturesFrom array. When I don't use composition-api, emit drawend changes array if there are more than one drawn features

ghettovoice commented 3 years ago

Hello @Nikitoring , something wrong with your demo

Снимок экрана 2020-12-07 в 12 18 57

In my demo I don't see any problems with synchroniation between drawend and drawn features array. https://jsfiddle.net/ghettovoice/Ln9qr135/110/

Can you fix your demo?

Nikitoring commented 3 years ago

Hello, @ghettovoice I fixed my demo https://codesandbox.io/s/drawendvuelayers-cflg9?file=/src/components/Map.vue It works if my drawend function looks like:

    const endDraw = ({ json }) => {
      console.log("new feature", json);
      console.log("drawn features", drawFeaturesFrom);
    };

Screenshot_2020-12-07 CodeSandbox

But newFeature is undefined

Thanks a lot

Nikitoring commented 3 years ago

It works when drawn features is more one

ghettovoice commented 3 years ago

@Nikitoring

This part is for v0.12.x.

({ json }) => {
      console.log("new feature", json);
      console.log("drawn features", drawFeaturesFrom);
    };

But as I understand you are using v0.11.x. And there was a bug, thanks for report! Upgrade to the v0.11.29