mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-01 04:24:02 +01:00
Improve handling of bounds calculation. Layers have to whitelist, vectors/markers can set themselves to ignore.
This commit is contained in:
@@ -163,6 +163,7 @@ L.Contao = L.Class.extend({
|
||||
// constructor arguments given, use them.
|
||||
if (feature.properties.arguments) {
|
||||
marker = L[type].apply(L[type], feature.properties.arguments);
|
||||
|
||||
L.Util.setOptions(marker, feature.properties.options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/**
|
||||
* Extend map so that it can calculate their bounds depending of the features with the property affectBounds.
|
||||
*/
|
||||
@@ -42,7 +43,7 @@ L.Map.include({
|
||||
_scanForBounds: function(layer) {
|
||||
var source;
|
||||
|
||||
if (layer.feature && layer.feature.properties && layer.feature.properties.affectBounds) {
|
||||
if (layer.feature && (!layer.feature.properties || !layer.feature.properties.ignoreForBounds)) {
|
||||
if (layer.getBounds) {
|
||||
source = layer.getBounds();
|
||||
|
||||
@@ -62,7 +63,17 @@ L.Map.include({
|
||||
this._dynamicBounds = L.latLngBounds(source, source);
|
||||
}
|
||||
}
|
||||
} else if (layer.eachLayer) {
|
||||
} else if (layer instanceof L.MarkerClusterGroup && layer.options.affectBounds) {
|
||||
source = layer.getBounds();
|
||||
|
||||
if (source.isValid()) {
|
||||
if (this._dynamicBounds) {
|
||||
this._dynamicBounds.extend(source);
|
||||
} else {
|
||||
this._dynamicBounds = L.latLngBounds(source.getSouthWest(), source.getNorthEast());
|
||||
}
|
||||
}
|
||||
} else if ((!layer.options || (layer.options && layer.options.affectBounds)) && layer.eachLayer) {
|
||||
layer.eachLayer(this._scanForBounds, this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user