netjsongraph.js icon indicating copy to clipboard operation
netjsongraph.js copied to clipboard

[fix] Remove existing points from map in appendData before calling render

Open pandafy opened this issue 1 year ago • 1 comments

Remove the existing points from the map in appendData before calling the render method. Otherwise, the original points are duplicated on the map.

pandafy avatar May 27 '24 13:05 pandafy

@nemesifier can you help me add a test for this?

I wrote this test, but the library complains that map.config.utils.appendData does not exists for the map object.

diff --git a/test/netjsongraph.render.test.js b/test/netjsongraph.render.test.js
index 1df3c00..227fd73 100644
--- a/test/netjsongraph.render.test.js
+++ b/test/netjsongraph.render.test.js
@@ -450,6 +450,23 @@ describe("Test netjsongraph GeoJSON properties", () => {
       });
     });
   });
+
+  test("appendData removes plotted points from leaflet", () => {
+    let data = {
+      type: "FeatureCollection",
+      features: [
+        {
+          type: "Feature",
+          properties: {},
+          geometry: {
+            type: "Point",
+            coordinates: [27.764892578124996, 46.01222384063236],
+          },
+        },
+      ],
+    }
+    map.config.utils.appendData(data, map);
+  });
 });
 

pandafy avatar May 27 '24 13:05 pandafy

Merging anyway with the test coverage decreased. Will open a dedicated issue to work on increasing it.

nemesifier avatar Jul 02 '24 19:07 nemesifier