mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-01 12:33:45 +01:00
107 lines
2.8 KiB
PHP
107 lines
2.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @package dev
|
||
|
|
* @author David Molineus <david.molineus@netzmacht.de>
|
||
|
|
* @copyright 2014 netzmacht creative David Molineus
|
||
|
|
* @license LGPL 3.0
|
||
|
|
* @filesource
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||
|
|
|
||
|
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||
|
|
use Netzmacht\LeafletPHP\Definition;
|
||
|
|
use Netzmacht\LeafletPHP\Definition\Map;
|
||
|
|
|
||
|
|
class MapMapper extends AbstractMapper
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Class of the model being build.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\MapModel';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Class of the definition being created.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Map';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @inheritdoc
|
||
|
|
*/
|
||
|
|
protected function initialize()
|
||
|
|
{
|
||
|
|
$this
|
||
|
|
->addOptions('center', 'zoom', 'zoomControl')
|
||
|
|
->addOptions('dragging', 'touchZoom', 'scrollWheelZoom', 'doubleClickZoom', 'boxZoom', 'tap', 'keyboard')
|
||
|
|
->addOptions('trackResize', 'closePopupOnClick', 'bounceAtZoomLimits')
|
||
|
|
->addConditionalOptions('adjustZoomExtra', array('minZoom', 'maxZoom'))
|
||
|
|
->addConditionalOptions('keyboard', array('keyboardPanOffset', 'keyboardZoomOffset'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @inheritdoc
|
||
|
|
*/
|
||
|
|
protected function doBuild(Definition $map, \Model $model, DefinitionMapper $builder)
|
||
|
|
{
|
||
|
|
if ($map instanceof Map && $model instanceof MapModel) {
|
||
|
|
$this->buildCustomOptions($map, $model);
|
||
|
|
$this->buildControls($map, $model, $builder);
|
||
|
|
$this->buildLayers($map, $model, $builder);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @inheritdoc
|
||
|
|
*/
|
||
|
|
protected function buildConstructArguments(\Model $model, DefinitionMapper $mapper)
|
||
|
|
{
|
||
|
|
return array(
|
||
|
|
$mapper->getMapId(),
|
||
|
|
$mapper->getMapId()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Build map custom options.
|
||
|
|
*
|
||
|
|
* @param Map $map The map being built.
|
||
|
|
* @param MapModel $model The map model.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
protected function buildCustomOptions(Map $map, MapModel $model)
|
||
|
|
{
|
||
|
|
if ($model->options) {
|
||
|
|
$map->setOptions(json_decode($model->options, true));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Build map controls.
|
||
|
|
*
|
||
|
|
* @param Map $map The map being built.
|
||
|
|
* @param MapModel $model The map model.
|
||
|
|
* @param DefinitionMapper $mapper The definition mapper.
|
||
|
|
*/
|
||
|
|
private function buildControls(Map $map, MapModel$model, DefinitionMapper $mapper)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Build map layers.
|
||
|
|
*
|
||
|
|
* @param Map $map The map being built.
|
||
|
|
* @param MapModel $model The map model.
|
||
|
|
* @param DefinitionMapper $mapper Definition mapper.
|
||
|
|
*/
|
||
|
|
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
}
|