ghettovoice / vuelayers

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

prevent two maps to show same features #489

Closed fernanduandrade closed 2 years ago

fernanduandrade commented 2 years ago

Hello! I'm using two maps in the same view, one to draw and show the features already saved and other to edit. When I'm editting it's supposed to load only one feature but instead it loads all the features, I have to close and open again to load only one but it's kinda weird, it doesnt load correctly. How can I prevent the map that I use to edit from loading the saved features and loads only one?

ghettovoice commented 2 years ago

Hello @fernanduandrade , you have 2 vl-map components on the same page, right? Each map has its own set of layers if you don't share them.
So provide only selected for edit feature for the vector source that is used in the second map. If the feature for edit is loading from some backend, then obviously you need to somehow filter out not needed features.

Maybe be I'm not fully understand you use case. If you show me some approx demo of your app, it would helpful

fernanduandrade commented 2 years ago

Sure, my English is bad so sorry if you didnt understand at first. The first vl-map shows one blue feature and the pink ones are like sub features that belongs to blue one, the purpose of the first vl-map it's just to show the main feature and the user add pink features to it. image The second vl-map in this page it's for editing pink features, so the correct flow would be like this when I'm editing. image

Sometimes when I'm editing it loads all the pink features from the first vl-map, even if I'm passing only one to second vl-map. What I'm doing as a workaround is this, I gave the second vl-map a :key, then hide the first vl-map when I click on edit, then I try to wait the response from the backend to get the information about the feature to edit and at the end after i get the response I change the state of :key so the second vl-map rerender again loading only one feature.

ghettovoice commented 2 years ago

OK, no prob 👌 My english isn't perfect too.

Yeh, I see now. Can you also show me your code? By screenshots hard to understand how you actually load features to the first and second map. Do you using GeoJSON WFS server or load them via custom XHR request? Which request is sent when you trying to load single selected feature to the second map?

If we for example remove backend part and just make it only on the client side, you can see my simplest example https://jsfiddle.net/ghettovoice/Ln9qr135/255/. As you can see there is no problem pass selected feature to the second map with a simple copy of GeoJSON feature. So I think the problem somewhere in the client->server negotiation, at least that's how it looks to me so far.

fernanduandrade commented 2 years ago

Unfortunately I can't show the code, but you gave me some ideas. I may have made complex so I'm getting side effects.