diff --git a/assets/maps/contao-leaflet.js b/assets/maps/contao-leaflet.js index 02e1dc1..f71e70a 100644 --- a/assets/maps/contao-leaflet.js +++ b/assets/maps/contao-leaflet.js @@ -1 +1 @@ -L.Contao=L.Class.extend({includes:L.Mixin.Events,attribution:' | netzmacht creative',maps:{},icons:{},initialize:function(){L.Icon.Default.imagePath="assets/leaflet/libs/leaflet/images",this.setGeoJsonListeners(L.GeoJSON)},addMap:function(t,e){return e.map.attributionControl.setPrefix(e.map.attributionControl.options.prefix+this.attribution),this.maps[t]=e,this.fire("map:added",{id:t,map:e}),this},getMap:function(t){return"undefined"==typeof this.maps[t]?null:this.maps[t]},addIcon:function(t,e){return this.icons[t]=e,this.fire("icon:added",{id:t,icon:e}),this},loadIcons:function(t){for(var e=0;ei&&(n[n.length]=[e,t].join("=")),document.location.pathname+n.join("&")}}),L.contao=new L.Contao,L.Map.include({_dynamicBounds:null,calculateFeatureBounds:function(t,e){if(t){if(!this.options.adjustBounds&&!e)return;this._scanForBounds(t)}else this.eachLayer(this._scanForBounds,this);this._dynamicBounds&&this.fitBounds(this._dynamicBounds)},_scanForBounds:function(t){var e;!t.feature||t.feature.properties&&t.feature.properties.ignoreForBounds?t instanceof L.MarkerClusterGroup&&t.options.affectBounds?(e=t.getBounds(),e.isValid()&&(this._dynamicBounds?this._dynamicBounds.extend(e):this._dynamicBounds=L.latLngBounds(e.getSouthWest(),e.getNorthEast()))):(!t.options||t.options&&t.options.affectBounds)&&t.eachLayer&&t.eachLayer(this._scanForBounds,this):t.getBounds?(e=t.getBounds(),e.isValid()&&(this._dynamicBounds?this._dynamicBounds.extend(e):this._dynamicBounds=L.latLngBounds(e.getSouthWest(),e.getNorthEast()))):t.getLatLng&&(e=t.getLatLng(),this._dynamicBounds?this._dynamicBounds.extend(e):this._dynamicBounds=L.latLngBounds(e,e))}}); \ No newline at end of file +L.Contao=L.Class.extend({includes:L.Mixin.Events,attribution:' | netzmacht creative',maps:{},icons:{},initialize:function(){L.Icon.Default.imagePath="assets/leaflet/libs/leaflet/images",this.setGeoJsonListeners(L.GeoJSON)},addMap:function(t,e){return e.map.attributionControl.setPrefix(e.map.attributionControl.options.prefix+this.attribution),this.maps[t]=e,this.fire("map:added",{id:t,map:e}),this},getMap:function(t){return"undefined"==typeof this.maps[t]?null:this.maps[t]},addIcon:function(t,e){return this.icons[t]=e,this.fire("icon:added",{id:t,icon:e}),this},loadIcons:function(t){for(var e=0;ei&&(n[n.length]=[e,t].join("=")),document.location.pathname+n.join("&")}}),L.contao=new L.Contao,L.Map.include({_dynamicBounds:null,calculateFeatureBounds:function(t,e){if(t){if(!this.options.adjustBounds&&!e)return;this._scanForBounds(t)}else this.eachLayer(this._scanForBounds,this);this._dynamicBounds&&this.fitBounds(this._dynamicBounds)},_scanForBounds:function(t){var e;!t.feature||t.feature.properties&&t.feature.properties.ignoreForBounds?L.MarkerClusterGroup&&t instanceof L.MarkerClusterGroup&&t.options.affectBounds?(e=t.getBounds(),e.isValid()&&(this._dynamicBounds?this._dynamicBounds.extend(e):this._dynamicBounds=L.latLngBounds(e.getSouthWest(),e.getNorthEast()))):(!t.options||t.options&&t.options.affectBounds)&&t.eachLayer&&t.eachLayer(this._scanForBounds,this):t.getBounds?(e=t.getBounds(),e.isValid()&&(this._dynamicBounds?this._dynamicBounds.extend(e):this._dynamicBounds=L.latLngBounds(e.getSouthWest(),e.getNorthEast()))):t.getLatLng&&(e=t.getLatLng(),this._dynamicBounds?this._dynamicBounds.extend(e):this._dynamicBounds=L.latLngBounds(e,e))}}); \ No newline at end of file diff --git a/assets/maps/src/Map.calculateFeatureBounds.js b/assets/maps/src/Map.calculateFeatureBounds.js index 7eb844e..80cba71 100644 --- a/assets/maps/src/Map.calculateFeatureBounds.js +++ b/assets/maps/src/Map.calculateFeatureBounds.js @@ -63,7 +63,7 @@ L.Map.include({ this._dynamicBounds = L.latLngBounds(source, source); } } - } else if (layer instanceof L.MarkerClusterGroup && layer.options.affectBounds) { + } else if (L.MarkerClusterGroup && layer instanceof L.MarkerClusterGroup && layer.options.affectBounds) { source = layer.getBounds(); if (source.isValid()) { diff --git a/module/dca/tl_leaflet_layer.php b/module/dca/tl_leaflet_layer.php index 276bc7c..6fa2fd2 100644 --- a/module/dca/tl_leaflet_layer.php +++ b/module/dca/tl_leaflet_layer.php @@ -173,9 +173,6 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array 'polygonOptions', 'iconCreateFunction', 'disableDefaultStyle' - ), - '+active' => array( - 'affectBounds' ) ), ), diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php index 660a027..480a529 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkerClusterLayerMapper.php @@ -87,8 +87,6 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css||static'; } - $definition->setOption('affectBounds', (bool) $model->affectBounds); - $collection = LayerModel::findBy( array('pid=?', 'active=1'), array($model->id), diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php index 19632cf..11eb604 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php @@ -68,8 +68,14 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper if ($model->pointToLayer || $model->affectBounds) { $layer = new GeoJson($this->getElementId($model, $elementId)); - $layer->setPointToLayer(new Expression($model->pointToLayer)); - $layer->setOption('affectBounds', (bool) $model->affectBounds); + + if ($model->pointToLayer ) { + $layer->setPointToLayer(new Expression($model->pointToLayer)); + } + + if ($model->affectBounds) { + $layer->setOption('affectBounds', (bool) $model->affectBounds); + } return array($this->getElementId($model, $elementId), RequestUrl::create($model->id), array(), $layer); }