umap-project / umap

uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.

Home Page:https://umap-project.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Polyline disapears on layer movement

isidroas opened this issue · comments

To Reproduce
It is easy to replicate. Move a polyline from one layer to another and it will disappear and you will not able to find it either layer.

For example, you can test it here: https://umap.openstreetmap.fr/en/map/untitled-map_1086366#6/24.847/-72.092

  • OS: Ubuntu
  • Browser Firefox and Chromium

Thanks for the report!

Seems related to the order of removing a feature from a layer.

Traceback:

image

Quick fix:

diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js
index 2ca9ee62..4ab4462c 100644
--- a/umap/static/umap/js/umap.layer.js
+++ b/umap/static/umap/js/umap.layer.js
@@ -913,10 +913,10 @@ U.DataLayer = L.Evented.extend({
 
   removeLayer: function (feature) {
     const id = L.stamp(feature)
+    this.layer.removeLayer(feature)
     feature.disconnectFromDataLayer(this)
     this._index.splice(this._index.indexOf(id), 1)
     delete this._layers[id]
-    this.layer.removeLayer(feature)
     delete this.map.features_index[feature.getSlug()]
     if (this.hasDataLoaded()) this.fire('datachanged')
   },

But needs further investigation, and a unit test.

@almet if you are onboard tomorrow, could you have a look (I'm off) ? Worth a patch release too I'd say.
Otherwise I'll try tomorrow night!

Thank you! 🙏

Just in time for my trip, now I can now move the features to a layer for each day!