Files
contao-leaflet-maps/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php

69 lines
1.6 KiB
PHP
Raw Normal View History

2015-01-07 17:59:56 +01:00
<?php
/**
2016-10-11 10:40:15 +02:00
* @package contao-leaflet-maps
2015-01-07 17:59:56 +01:00
* @author David Molineus <david.molineus@netzmacht.de>
2016-10-11 10:40:15 +02:00
* @copyright 2014-2016 netzmacht David Molineus
2015-01-07 17:59:56 +01:00
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
use Netzmacht\Contao\Leaflet\Filter\Filter;
2015-01-07 17:59:56 +01:00
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\LeafletPHP\Definition;
2016-10-05 13:35:04 +02:00
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
use Netzmacht\LeafletPHP\Value\LatLng;
2015-01-07 17:59:56 +01:00
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
2015-01-12 19:03:29 +01:00
/**
* Class CircleMapper maps the database model to the circle definition.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Vector
*/
2015-01-07 17:59:56 +01:00
class CircleMapper extends AbstractVectorMapper
{
/**
* Class of the definition being created.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Circle';
/**
* Layer type.
*
* @var string
*/
protected static $type = 'circle';
2015-01-12 19:03:29 +01:00
/**
* {@inheritdoc}
*/
2015-01-07 17:59:56 +01:00
protected function initialize()
{
parent::initialize();
$this->optionsBuilder->addOption('radius');
2015-01-07 17:59:56 +01:00
}
2015-01-12 19:03:29 +01:00
/**
* {@inheritdoc}
*/
protected function build(
2015-01-07 17:59:56 +01:00
Definition $definition,
\Model $model,
2015-01-20 16:38:23 +01:00
DefinitionMapper $mapper,
Filter $filter = null,
2015-01-20 16:38:23 +01:00
Definition $parent = null
2015-01-07 17:59:56 +01:00
) {
parent::build($definition, $model, $mapper, $filter);
2015-01-07 17:59:56 +01:00
2016-10-05 13:35:04 +02:00
if ($definition instanceof CircleMarker) {
2015-01-07 17:59:56 +01:00
$definition->setLatLng(LatLng::fromString($model->coordinates));
}
}
}