netjsongraph.js
netjsongraph.js copied to clipboard
[fix] Remove existing points from map in appendData before calling render
Remove the existing points from the map in appendData before calling the render method. Otherwise, the original points are duplicated on the map.
@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);
+ });
});
Merging anyway with the test coverage decreased. Will open a dedicated issue to work on increasing it.