2016-11-09 10:27:18 +01:00
|
|
|
<?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;
|
|
|
|
|
|
2016-11-14 11:00:10 +01:00
|
|
|
use Model;
|
|
|
|
|
use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
|
2016-11-09 10:27:18 +01:00
|
|
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
|
|
|
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
|
|
|
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
|
|
|
|
use Netzmacht\LeafletPHP\Definition;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class OverpassLayerMapper
|
|
|
|
|
*
|
|
|
|
|
* @package Netzmacht\Contao\Leaflet\Mapper\Layer
|
|
|
|
|
*/
|
|
|
|
|
class OverpassLayerMapper extends AbstractLayerMapper
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The definition type.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected static $type = 'overpass';
|
|
|
|
|
|
2016-11-09 11:23:26 +01:00
|
|
|
/**
|
|
|
|
|
* The definition class.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2016-11-14 11:00:10 +01:00
|
|
|
protected static $definitionClass = 'Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer';
|
2016-11-09 11:23:26 +01:00
|
|
|
|
2016-11-09 10:27:18 +01:00
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
|
|
|
|
protected function initialize()
|
|
|
|
|
{
|
|
|
|
|
parent::initialize();
|
|
|
|
|
|
|
|
|
|
$this->optionsBuilder
|
2016-11-09 11:23:26 +01:00
|
|
|
->addOption('query', 'overpassQuery')
|
2016-11-14 11:00:10 +01:00
|
|
|
->addOption('minZoom')
|
|
|
|
|
->addOption('boundsMode')
|
2016-11-09 11:23:26 +01:00
|
|
|
->addOption('overpassEndpoint', 'endpoint');
|
2016-11-09 10:27:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
|
|
|
|
protected function build(
|
|
|
|
|
Definition $definition,
|
2016-11-14 11:00:10 +01:00
|
|
|
Model $model,
|
2016-11-09 10:27:18 +01:00
|
|
|
DefinitionMapper $mapper,
|
|
|
|
|
Filter $filter = null,
|
|
|
|
|
Definition $parent = null
|
|
|
|
|
) {
|
|
|
|
|
if (!$definition instanceof OverpassLayer) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-14 11:00:10 +01:00
|
|
|
if ($model->pointToLayer) {
|
|
|
|
|
$definition->setPointToLayer(new Expression($model->pointToLayer));
|
|
|
|
|
}
|
2016-11-09 10:27:18 +01:00
|
|
|
|
2016-11-14 11:00:10 +01:00
|
|
|
if ($model->onEachFeature) {
|
|
|
|
|
$definition->setOnEachFeature(new Expression($model->onEachFeature));
|
2016-11-09 10:27:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|