Add option to replace default attribution control.

This commit is contained in:
David Molineus
2015-01-22 16:17:21 +01:00
parent 99daeac4fb
commit f68f623288
3 changed files with 17 additions and 1 deletions

View File

@@ -115,7 +115,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
'config' => array('maxWidth', 'metric', 'imperial', 'updateWhenIdle')
),
'attribution extends default' => array(
'config' => array('attributions', 'prefix')
'config' => array('attributions', 'prefix', 'disableDefault')
),
'loading extends default' => array(
'config' => array('separate', 'zoomControl', 'spinjs')
@@ -418,5 +418,14 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'disableDefault' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'],
'exclude' => true,
'inputType' => 'checkbox',
'default' => true,
'eval' => array('tl_class' => 'w50 m12'),
'sql' => "char(1) NOT NULL default ''"
),
),
);

View File

@@ -75,6 +75,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'][0] = 'Button tit
$GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'][1] = 'Title attribute of the control button.';
$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'][0] = 'Always simulate fullscreen';
$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'][1] = 'Simulate fullscreen no matter if the browser supports the Fullscreen API.';
$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'][0] = 'Replace default control';
$GLOBALS['TL_LANG']['tl_leaflet_control']['disableDefault'][1] = 'If enabled the default control will be disabled.';
$GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft'][0] = 'Bottom left';
$GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft'][1] = 'Bottom left of the map.';

View File

@@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
use Netzmacht\LeafletPHP\Definition\Map;
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
/**
@@ -61,6 +62,10 @@ class AttributionControlMapper extends AbstractControlMapper
return;
}
if ($model->disableDefault && $parent instanceof Map) {
$parent->setAttributionControl(false);
}
$attributions = deserialize($model->attributions, true);
foreach ($attributions as $attribution) {