From f22906b8b624aaaa60916fb59b771a59ee63145b Mon Sep 17 00:00:00 2001 From: David Molineus Date: Tue, 11 Oct 2016 10:25:28 +0200 Subject: [PATCH] Implement zoomSnap and zoomDelta. --- module/dca/tl_leaflet_map.php | 32 ++++++++++++++++++- module/languages/en/tl_leaflet_map.php | 4 +++ .../Contao/Leaflet/Mapper/MapMapper.php | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/module/dca/tl_leaflet_map.php b/module/dca/tl_leaflet_map.php index 8221698..ab7b816 100644 --- a/module/dca/tl_leaflet_map.php +++ b/module/dca/tl_leaflet_map.php @@ -128,7 +128,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array ), 'adjustZoomExtra' => array( 'minZoom', - 'maxZoom' + 'maxZoom', + 'zoomSnap', + 'zoomDelta', ), 'locate' => array( ':hide', @@ -289,6 +291,34 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array ), 'sql' => "int(4) NULL" ), + 'zoomSnap' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => array( + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true + ), + 'sql' => "varchar(4) NULL" + ), + 'zoomDelta' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => array( + 'maxlength' => 4, + 'rgxp' => 'digit', + 'tl_class' => 'w50', + 'includeBlankOption' => true, + 'nullIfEmpty' => true + ), + 'sql' => "varchar(4) NULL" + ), 'dragging' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_map']['dragging'], diff --git a/module/languages/en/tl_leaflet_map.php b/module/languages/en/tl_leaflet_map.php index 23e3dfd..71dcb94 100644 --- a/module/languages/en/tl_leaflet_map.php +++ b/module/languages/en/tl_leaflet_map.php @@ -55,6 +55,10 @@ $GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'][0] = 'Minimum zoom $GLOBALS['TL_LANG']['tl_leaflet_map']['minZoom'][1] = 'Minimum zoom level of the map. Overrides any minZoom set on map layers.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][0] = 'Maximum zoom level'; $GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][1] = 'Maximum zoom level of the map. This overrides any maxZoom set on map layers.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'][0] = 'Zoom snap'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomSnap'][1] = 'Forces the map\'s zoom level to always be a multiple of the number. Default is 1.'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'][0] = 'Zoom delta'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['zoomDelta'][1] = 'Controls how much the map\'s zoom level will change after zoom in or zoom out.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'][0] = 'Add default zoom control'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomControl'][1] = 'Whether the zoom control is added to the map by default.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'][0] = 'Bounce at zoom limits'; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php index e4d1bcb..f0cb134 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php @@ -50,7 +50,7 @@ class MapMapper extends AbstractMapper ->addOptions('center', 'zoom', 'zoomControl') ->addOptions('dragging', 'touchZoom', 'scrollWheelZoom', 'doubleClickZoom', 'boxZoom', 'tap', 'keyboard') ->addOptions('trackResize', 'closeOnClick', 'bounceAtZoomLimits') - ->addConditionalOptions('adjustZoomExtra', array('minZoom', 'maxZoom')) + ->addConditionalOptions('adjustZoomExtra', array('minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta')) ->addConditionalOptions('keyboard', array('keyboardPanOffset', 'keyboardZoomOffset')); }