mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 11:04:08 +01:00
Implement overpass layer.
This commit is contained in:
@@ -98,6 +98,7 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLa
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper';
|
||||
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
|
||||
return new \Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper(
|
||||
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::MAP_ASSETS]
|
||||
|
||||
@@ -213,7 +213,20 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array
|
||||
'reuseTiles',
|
||||
'bounds'
|
||||
)
|
||||
)
|
||||
),
|
||||
'overpass extends default' => array(
|
||||
'config' => array(
|
||||
'overpassQuery',
|
||||
'overpassEndpoint',
|
||||
'overpassCallback',
|
||||
'minZoom',
|
||||
),
|
||||
'+expert' => array(
|
||||
'minZoomIndicatorPosition',
|
||||
'minZoomIndicatorMessageNoLayer',
|
||||
'minZoomIndicatorMessage',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
'metasubselectpalettes' => array(
|
||||
@@ -783,5 +796,72 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array
|
||||
'eval' => array('maxlength' => 5, 'rgxp' => 'digit', 'tl_class' => 'w50', 'nullIfEmpty' => true),
|
||||
'sql' => "int(9) NOT NULL default '0'"
|
||||
),
|
||||
'overpassQuery' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassQuery'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'textarea',
|
||||
'eval' => array(
|
||||
'preserveTags' => true,
|
||||
'decodeEntities' => true,
|
||||
'allowHtml' => true,
|
||||
'rte' => 'ace',
|
||||
'tl_class' => 'clr'
|
||||
),
|
||||
'sql' => "mediumtext NULL"
|
||||
),
|
||||
'overpassEndpoint' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassEndpoint'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => null,
|
||||
'eval' => array('tl_class' => 'long'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'overpassCallback' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['overpassCallback'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'textarea',
|
||||
'eval' => array(
|
||||
'preserveTags' => true,
|
||||
'decodeEntities' => true,
|
||||
'allowHtml' => true,
|
||||
'rte' => 'ace|javascript',
|
||||
'tl_class' => 'clr'
|
||||
),
|
||||
'sql' => "mediumtext NULL"
|
||||
),
|
||||
'minZoomIndicatorPosition' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorPosition'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'filter' => true,
|
||||
'sorting' => true,
|
||||
'options' => array('topleft', 'topright', 'bottomleft', 'bottomright'),
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_leaflet_layer'],
|
||||
'eval' => array('mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50', 'helpwizard' => true),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'minZoomIndicatorMessage' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorMessage'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => null,
|
||||
'eval' => array('tl_class' => 'long'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
'minZoomIndicatorMessageNoLayer' => array
|
||||
(
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_layer']['minZoomIndicatorMessageNoLayer'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'default' => null,
|
||||
'eval' => array('tl_class' => 'long'),
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package netzmacht
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2016 netzmacht David Molineus. All rights reserved.
|
||||
* @filesource
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder;
|
||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Plugins\OverpassLayer\OverpassLayer;
|
||||
|
||||
/**
|
||||
* Class OverpassLayerMapper
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\Mapper\Layer
|
||||
*/
|
||||
class OverpassLayerMapper extends AbstractLayerMapper
|
||||
{
|
||||
/**
|
||||
* The definition type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $type = 'overpass';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->optionsBuilder
|
||||
->addOption('overpassQuery', 'query')
|
||||
->addConditionalOption('minZoom')
|
||||
->addConditionalOption('overpassEndpoint', 'endpoint');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $mapper,
|
||||
Filter $filter = null,
|
||||
Definition $parent = null
|
||||
) {
|
||||
if (!$definition instanceof OverpassLayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
$minZoomIndicatorOptions = $definition->getMinZoomIndicatorOptions();
|
||||
$minZoomIndicatorOptionsBuilder = new OptionsBuilder();
|
||||
$minZoomIndicatorOptionsBuilder
|
||||
->addConditionalOption('minZoomIndicatorPosition', 'position')
|
||||
->addConditionalOption('minZoomIndicatorMessageNoLayer', 'minZoomMessageNoLayer')
|
||||
->addConditionalOption('minZoomIndicatorMessage', 'minZoomMessage');
|
||||
|
||||
$minZoomIndicatorOptionsBuilder->build($minZoomIndicatorOptions, $model);
|
||||
|
||||
if ($model->overpassCallback) {
|
||||
$definition->setCallback(new Expression($model->overpassCallback));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ class OptionsBuilder
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function buildConditionals(Definition $definition, \Model $model)
|
||||
private function buildConditionals($definition, \Model $model)
|
||||
{
|
||||
foreach ($this->conditional as $column => $conditions) {
|
||||
foreach ($conditions as $value => $options) {
|
||||
|
||||
Reference in New Issue
Block a user