From ee9d293d2e77e928ae9fc480775439e66fc01bb7 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Mon, 29 Dec 2014 16:23:08 +0100 Subject: [PATCH] Ongoing development. --- module/config/config.php | 27 ++++++++++++------- module/languages/en/tl_leaflet_map.php | 11 ++++++++ module/templates/be_leaflet_geocode.html5 | 4 +-- module/templates/ce_leaflet_map.html5 | 15 +++++++++-- src/Netzmacht/Contao/Leaflet/ContaoAssets.php | 2 +- src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php | 14 ++++++++++ .../Leaflet/Subscriber/BootSubscriber.php | 2 +- .../Leaflet/Subscriber/EncoderSubscriber.php | 5 +--- 8 files changed, 60 insertions(+), 20 deletions(-) diff --git a/module/config/config.php b/module/config/config.php index 5c25662..e9dd75f 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -4,7 +4,7 @@ * Backend module. */ $GLOBALS['BE_MOD']['content']['leaflet'] = array( - 'tables' => array('tl_leaflet_map'), + 'tables' => array('tl_leaflet_map', 'tl_leaflet_layer'), 'icon' => 'system/modules/leaflet/assets/img/leaflet.png', ); @@ -17,7 +17,8 @@ $GLOBALS['TL_CTE']['includes']['leaflet'] = 'Netzmacht\Contao\Leaflet\LeafletMap /* * Models. */ -$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel'; +$GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapModel'; +$GLOBALS['TL_MODELS']['tl_leaflet_layer'] = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; /* @@ -27,7 +28,7 @@ $GLOBALS['TL_MODELS']['tl_leaflet_map'] = 'Netzmacht\Contao\Leaflet\Model\MapMod */ $GLOBALS['LEAFLET_MAPPERS'] = array(); $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper'; - +$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper'; /* * Leaflet encoders. @@ -48,6 +49,12 @@ $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\RasterEncoder'; $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\LeafletPHP\Encoder\VectorEncoder'; $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSubscriber'; +$GLOBALS['LEAFLET_LAYERS'][] = 'provider'; + +/* + * Leaflet tile layer providers. + */ +require_once __DIR__ . '/leaflet_providers.php'; /* * Leaflet assets. @@ -60,17 +67,17 @@ $GLOBALS['LEAFLET_ENCODERS'][] = 'Netzmacht\Contao\Leaflet\Subscriber\EncoderSub * - file: An file path relative to the Contao Root. * - source: Inline css/javascript. */ -$GLOBALS['LEAFLET_ASSETS']['contao'] = array( +$GLOBALS['LEAFLET_ASSETS']['leaflet'] = array( + 'css' => array( + array('system/modules/leaflet/assets/leaflet/leaflet/leaflet.css', 'file') + ), 'javascript' => array( - array() + array('system/modules/leaflet/assets/leaflet/leaflet/leaflet.js', 'file') ) ); -$GLOBALS['LEAFLET_ASSETS']['leaflet'] = array( - 'css' => array( - array('http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css', 'url') - ), +$GLOBALS['LEAFLET_ASSETS']['leaflet-providers'] = array( 'javascript' => array( - array('http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js?3', 'url') + array('system/modules/leaflet/assets/leaflet/leaflet-providers/leaflet-providers.js', 'file') ) ); diff --git a/module/languages/en/tl_leaflet_map.php b/module/languages/en/tl_leaflet_map.php index 20fc413..19837fb 100644 --- a/module/languages/en/tl_leaflet_map.php +++ b/module/languages/en/tl_leaflet_map.php @@ -3,6 +3,8 @@ $GLOBALS['TL_LANG']['tl_leaflet_map']['title_legend'] = 'Title'; $GLOBALS['TL_LANG']['tl_leaflet_map']['interaction_legend'] = 'Interaction controls'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoom_legend'] = 'Center and zoom'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['controls_legend'] = 'Control widgets'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['expert_legend'] = 'Expert settings'; $GLOBALS['TL_LANG']['tl_leaflet_map']['title'][0] = 'Title'; $GLOBALS['TL_LANG']['tl_leaflet_map']['title'][1] = 'Title of the map.'; @@ -40,6 +42,12 @@ $GLOBALS['TL_LANG']['tl_leaflet_map']['maxZoom'][0] = 'Maximum zoom l $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']['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'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['bounceAtZoomLimits'][1] = 'Disable if you don\'t want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['options'][0] = 'Extra options'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['options'][1] = 'Add extra map options as valid json. See http://leafletjs.com/reference.html#map-options'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'][0] = 'Adjust extra zoom settings'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['adjustZoomExtra'][1] = 'Enable if you want to adjust minimum and maximum zoom as well'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][0] = 'Disable'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues'][''][1] = 'Disable zoom function.'; @@ -47,3 +55,6 @@ $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][0] = 'Enable'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['1'][1] = 'Enable zoom function.'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][0] = 'Center'; $GLOBALS['TL_LANG']['tl_leaflet_map']['zoomValues']['center'][1] = 'If passed \'center\', it will zoom to the center of the view regardless of where the mouse was.'; + +$GLOBALS['TL_LANG']['tl_leaflet_map']['searchPosition'] = 'Search'; +$GLOBALS['TL_LANG']['tl_leaflet_map']['applyPosition'] = 'Apply position'; diff --git a/module/templates/be_leaflet_geocode.html5 b/module/templates/be_leaflet_geocode.html5 index 476a6d5..89e0b9a 100644 --- a/module/templates/be_leaflet_geocode.html5 +++ b/module/templates/be_leaflet_geocode.html5 @@ -12,7 +12,7 @@ }).addTo(map); var geocoder = L.Control.geocoder({ collapsed: false, - placeholder: 'Suchen' + placeholder: '' }).addTo(map); geocoder.markGeocode = function(result) { @@ -21,7 +21,7 @@ var element = $('field; ?>'); link.set('style', 'margin-left: 10px;'); - link.appendText('übernehmen'); + link.appendText(''); link.addEvent('click', function(e) { e.stop(); diff --git a/module/templates/ce_leaflet_map.html5 b/module/templates/ce_leaflet_map.html5 index 9088421..711f43e 100644 --- a/module/templates/ce_leaflet_map.html5 +++ b/module/templates/ce_leaflet_map.html5 @@ -1,6 +1,17 @@ + +
cssID; ?>style): ?> style="style; ?>"> + + headline): ?> + <hl; ?>>headline; ?>hl; ?>> + +
+map): ?> + + +
+ + diff --git a/src/Netzmacht/Contao/Leaflet/ContaoAssets.php b/src/Netzmacht/Contao/Leaflet/ContaoAssets.php index d836f26..2f2ea9a 100644 --- a/src/Netzmacht/Contao/Leaflet/ContaoAssets.php +++ b/src/Netzmacht/Contao/Leaflet/ContaoAssets.php @@ -54,7 +54,7 @@ class ContaoAssets implements Assets break; case static::TYPE_FILE: - $stylesheet .= '||static'; + $stylesheet .= '|all|static'; // no break default: diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php b/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php index e1fb284..54be2be 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php @@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Dca; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Mapper\MapMapper; +use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\Contao\Leaflet\Model\MapModel; use Netzmacht\LeafletPHP\Definition\Type\LatLng; @@ -60,4 +61,17 @@ class Leaflet return $template->parse(); } + public function getLayers() + { + $options = array(); + $collection = LayerModel::findBy('pid', '0', array('order' => 'title')); + + if ($collection) { + foreach ($collection as $model) { + $options[$model->id] = $model->title; + } + } + + return $options; + } } diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php index 44c8b7d..c94b033 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php @@ -112,6 +112,6 @@ class BootSubscriber implements EventSubscriberInterface */ public function loadAssets() { - $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/leaflet/assets/js/contao-leaflet.js'; + $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/leaflet/assets/js/contao-leaflet.js|static'; } } diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php index 7d6b2b3..fbf4a3e 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php @@ -47,14 +47,11 @@ class EncoderSubscriber implements EventSubscriberInterface if ($object instanceof Map) { $attribution = <<netzmacht creative' ); HTML; $event->getOutput()->addLine($attribution); - - $event->getOutput()->addLine("var tileLayer = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: \"test\"}); -tileLayer.addTo(map);"); } }