diff --git a/Facades/AbstractAjaxFacade/Elements/LeafletTrait.php b/Facades/AbstractAjaxFacade/Elements/LeafletTrait.php index 0be87be7b..e5cddd233 100644 --- a/Facades/AbstractAjaxFacade/Elements/LeafletTrait.php +++ b/Facades/AbstractAjaxFacade/Elements/LeafletTrait.php @@ -825,7 +825,7 @@ function() { oLayer.clearLayers(); oLayer.addData(aGeoJson); - if (oClusterLayer !== null) { + if ('{$isClusteringMarkers}') { oClusterLayer.clearLayers().addLayer(oLayer); } {$this->buildJsAutoZoom('oLayer', $layer->getAutoZoom())} @@ -1038,17 +1038,17 @@ function visit(value, depth) { } // create markers for eacht top coordinate of every geometry within our geoJSON - const markerCoords = topMostCoordinates(feature); - oClusterLayer?.clearLayers(); - for (const [lng, lat] of markerCoords) { - const oMarker = L.marker([lat, lng], { - icon: {$this->buildJsMarkerIcon($layer, 'feature.properties.data')}, - draggable: false, - autoPan: false, - $markerProps - }); - - if (oClusterLayer) { + if (oClusterLayer) { + oClusterLayer.clearLayers(); + const markerCoords = topMostCoordinates(feature); + for (const [lng, lat] of markerCoords) { + const oMarker = L.marker([lat, lng], { + icon: {$this->buildJsMarkerIcon($layer, 'feature.properties.data')}, + draggable: false, + autoPan: false, + $markerProps + }); + oClusterLayer.addLayer(oMarker); } } @@ -1058,7 +1058,6 @@ function visit(value, depth) { $clusterInitJs = <<buildJsLeafletVar()}) JS; }