Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions Facades/AbstractAjaxFacade/Elements/LeafletTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ function() {

oLayer.clearLayers();
oLayer.addData(aGeoJson);
if (oClusterLayer !== null) {
if ('{$isClusteringMarkers}') {
oClusterLayer.clearLayers().addLayer(oLayer);
}
{$this->buildJsAutoZoom('oLayer', $layer->getAutoZoom())}
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -1058,7 +1058,6 @@ function visit(value, depth) {
$clusterInitJs = <<<JS

oClusterLayer = L.layerGroup();
oClusterLayer.addLayer(oLayer);
JS;

}
Expand Down Expand Up @@ -1106,6 +1105,8 @@ function visit(value, depth) {
}
});

// If we are displaying markers, especially if we cluster them, the cluster layer will serve as
// a wrapper for rendering all map markers.
var oClusterLayer = {$clusterInitJs};

{$initEditingJs}
Expand All @@ -1116,11 +1117,15 @@ function visit(value, depth) {
return;
}
oLayer._exfRefresh(oEvent);
// If we have a clustering wrapper, we have to ensure the marker layer is added to it,
// after refreshes or else it won't render.
if (oClusterLayer) {
oClusterLayer.addLayer(oLayer);
}
});

oLayer._exfRefresh();

return oClusterLayer ? oClusterLayer : oLayer;
return oClusterLayer ?? oLayer;
})({$this->buildJsLeafletVar()})
JS;
}
Expand Down