From 3795e61369ef8092aa25b159dbf72f79003d8419 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Fri, 6 Oct 2023 13:07:56 +0200 Subject: [PATCH] [fix] Fixed bugs in map bounds #548 Closes #548 --- .../device/static/monitoring/js/device-map.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openwisp_monitoring/device/static/monitoring/js/device-map.js b/openwisp_monitoring/device/static/monitoring/js/device-map.js index 33d18e82d..fcc9d258d 100644 --- a/openwisp_monitoring/device/static/monitoring/js/device-map.js +++ b/openwisp_monitoring/device/static/monitoring/js/device-map.js @@ -222,7 +222,6 @@ map.setView(map.geoJSON.getBounds().getCenter(), 10); } else { map.fitBounds(map.geoJSON.getBounds()); - map.setZoom(map.getZoom() - 1); } map.geoJSON.eachLayer(function (layer) { layer[layer.feature.geometry.type == 'Point' ? 'bringToFront' : 'bringToBack'](); @@ -238,7 +237,9 @@ if (bounds._southWest.lng < -180 && !netjsonGraph.westWorldFeaturesAppended) { let westWorldFeatures = window.structuredClone(netjsonGraph.data); westWorldFeatures.features.forEach(element => { - element.geometry.coordinates[0] -= 360; + if (element.geometry) { + element.geometry.coordinates[0] -= 360; + } }); netjsonGraph.utils.appendData(westWorldFeatures, netjsonGraph); netjsonGraph.westWorldFeaturesAppended = true; @@ -247,7 +248,9 @@ if (bounds._northEast.lng > 180 && !netjsonGraph.eastWorldFeaturesAppended) { let eastWorldFeatures = window.structuredClone(netjsonGraph.data); eastWorldFeatures.features.forEach(element => { - element.geometry.coordinates[0] += 360; + if (element.geometry) { + element.geometry.coordinates[0] += 360; + } }); netjsonGraph.utils.appendData(eastWorldFeatures, netjsonGraph); netjsonGraph.eastWorldFeaturesAppended = true;