diff --git a/module/languages/en/tl_leaflet_marker.php b/module/languages/en/tl_leaflet_marker.php index 12d8e8d..92dbb8c 100644 --- a/module/languages/en/tl_leaflet_marker.php +++ b/module/languages/en/tl_leaflet_marker.php @@ -48,5 +48,5 @@ $GLOBALS['TL_LANG']['tl_leaflet_marker']['icon'][0] = 'Icon'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['icon'][1] = 'Select a custom icon.'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['active'][0] = 'Activate marker'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['active'][1] = 'Only activated markers are rendered on the map.'; -$GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds'][0] = 'Ignore for bounds'; +$GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds'][0] = 'Exclude from bounds'; $GLOBALS['TL_LANG']['tl_leaflet_marker']['ignoreForBounds'][1] = 'Do not include this item in the bounds calculation.'; diff --git a/module/languages/en/tl_leaflet_vector.php b/module/languages/en/tl_leaflet_vector.php index a2269ec..7108a9e 100644 --- a/module/languages/en/tl_leaflet_vector.php +++ b/module/languages/en/tl_leaflet_vector.php @@ -53,5 +53,5 @@ $GLOBALS['TL_LANG']['tl_leaflet_vector']['bounds'][0] = 'Bounds'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['bounds'][1] = 'Each field defines a corner of the bounds as comma separated value (Latitude, longitude [, altitude]).'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['style'][0] = 'Style'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['style'][1] = 'Choose a style. If none defined, the default style of leaflet is used.'; -$GLOBALS['TL_LANG']['tl_leaflet_vector']['ignoreForBounds'][0] = 'Ignore for bounds'; +$GLOBALS['TL_LANG']['tl_leaflet_vector']['ignoreForBounds'][0] = 'Exclude from bounds'; $GLOBALS['TL_LANG']['tl_leaflet_vector']['ignoreForBounds'][1] = 'Do not include this item in the bounds calculation.'; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php index 11eb604..cf7baa4 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php @@ -17,6 +17,7 @@ use Netzmacht\Contao\Leaflet\Model\MarkerModel; use Netzmacht\Contao\Leaflet\Frontend\RequestUrl; use Netzmacht\JavascriptBuilder\Type\Expression; use Netzmacht\LeafletPHP\Definition; +use Netzmacht\LeafletPHP\Definition\GeoJson\Feature; use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection; use Netzmacht\LeafletPHP\Definition\Group\GeoJson; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; @@ -96,9 +97,11 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper LatLngBounds $bounds = null, Definition $parent = null ) { - $definition->setOption('affectBounds', (bool) $model->affectBounds); - if ($definition instanceof GeoJson) { + if ($model->affectBounds) { + $definition->setOption('affectBounds', true); + } + $collection = $this->loadMarkerModels($model); if ($collection) { @@ -107,7 +110,10 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper if ($marker instanceof Marker) { $feature = $marker->toGeoJsonFeature(); - $feature->setProperty('ignoreForBounds', ($item->ignoreForBounds)); + + if ($item->ignoreForBounds || !$model->affectBounds) { + $feature->setProperty('ignoreForBounds', true); + } $definition->addData($feature, true); } @@ -133,7 +139,13 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper $marker = $mapper->handle($item); if ($marker instanceof Marker) { - $feature->addFeature($marker->toGeoJsonFeature()); + $point = $marker->toGeoJsonFeature(); + + if ($point instanceof Feature && ($item->ignoreForBounds || !$model->affectBounds)) { + $point->setProperty('ignoreForBounds', true); + } + + $feature->addFeature($point); } } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php index 0be6844..92c5ef3 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php @@ -118,8 +118,8 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper if ($vector instanceof ConvertsToGeoJsonFeature) { $feature = $vector->toGeoJsonFeature(); - if ($feature instanceof Feature) { - $feature->setProperty('ignoreForBounds', (bool) $item->ignoreForBounds); + if ($feature instanceof Feature && ($item->ignoreForBounds || !$model->affectBounds)) { + $feature->setProperty('ignoreForBounds', true); } $definition->addData($feature, true); @@ -154,8 +154,8 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper } if ($vector instanceof GeoJsonFeature) { - if ($vector instanceof Feature) { - $vector->setProperty('ignoreForBounds', (bool) $item->ignoreForBounds); + if ($vector instanceof Feature && ($item->ignoreForBounds || !$model->affectBounds)) { + $vector->setProperty('ignoreForBounds', true); } $feature->addFeature($vector);