Skip to content

Commit 6e0d312

Browse files
pushpitkambojnemesifier
authored andcommitted
[change] Removed custom world-wrap code in favour of worldCopyJump: true #719
The netjsongraph.js library now ships `worldCopyJump: true` from leaflet by default so the JS code implementing the world-wrap was not needed anymore and hence has been removed. Closes #719
1 parent 4ae530f commit 6e0d312

1 file changed

Lines changed: 0 additions & 45 deletions

File tree

openwisp_monitoring/device/static/monitoring/js/device-map.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -480,51 +480,6 @@
480480
} catch (err) {
481481
console.error(gettext("Unable to fit NetJSON bounds:"), err);
482482
}
483-
484-
// Restrict horizontal panning to three wrapped worlds
485-
map.leaflet.setMaxBounds(
486-
L.latLngBounds(L.latLng(-90, -540), L.latLng(90, 540)),
487-
);
488-
489-
map.leaflet.on("moveend", (event) => {
490-
const netjsonGraph = map; // alias for clarity
491-
const bounds = event.target.getBounds();
492-
493-
// Ensure data.features exists; otherwise skip wrap logic
494-
if (!netjsonGraph.data || !Array.isArray(netjsonGraph.data.features)) {
495-
return; // nothing to wrap
496-
}
497-
498-
// When panning west past the dateline, clone features shifted −360°
499-
if (bounds._southWest.lng < -180 && !netjsonGraph.westWorldFeaturesAppended) {
500-
const westWorld = structuredClone(netjsonGraph.data);
501-
westWorld.features = westWorld.features.filter(
502-
(f) => !f.geometry || f.geometry.coordinates[0] <= 180,
503-
);
504-
westWorld.features.forEach((f) => {
505-
if (f.geometry) {
506-
f.geometry.coordinates[0] -= 360;
507-
}
508-
});
509-
netjsonGraph.utils.appendData(westWorld, netjsonGraph);
510-
netjsonGraph.westWorldFeaturesAppended = true;
511-
}
512-
513-
// When panning east past the dateline, clone features shifted +360°
514-
if (bounds._northEast.lng > 180 && !netjsonGraph.eastWorldFeaturesAppended) {
515-
const eastWorld = structuredClone(netjsonGraph.data);
516-
eastWorld.features = eastWorld.features.filter(
517-
(f) => !f.geometry || f.geometry.coordinates[0] >= -180,
518-
);
519-
eastWorld.features.forEach((f) => {
520-
if (f.geometry) {
521-
f.geometry.coordinates[0] += 360;
522-
}
523-
});
524-
netjsonGraph.utils.appendData(eastWorld, netjsonGraph);
525-
netjsonGraph.eastWorldFeaturesAppended = true;
526-
}
527-
});
528483
},
529484
});
530485

0 commit comments

Comments
 (0)