* @copyright 2014-2017 netzmacht David Molineus. All rights reserved. * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @filesource */ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; use Contao\Model; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Mapper\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Vector\Circle; use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker; use Netzmacht\LeafletPHP\Value\LatLng; /** * Class CircleMapper maps the database model to the circle definition. * * @package Netzmacht\Contao\Leaflet\Mapper\Vector */ class CircleMapper extends AbstractVectorMapper { /** * Class of the definition being created. * * @var string */ protected static $definitionClass = Circle::class; /** * Layer type. * * @var string */ protected static $type = 'circle'; /** * {@inheritdoc} */ protected function initialize() { parent::initialize(); $this->optionsBuilder->addOption('radius'); } /** * {@inheritdoc} */ protected function build( Definition $definition, Model $model, DefinitionMapper $mapper, Request $request = null, Definition $parent = null ) { parent::build($definition, $model, $mapper, $request); if ($definition instanceof CircleMarker) { $definition->setLatLng(LatLng::fromString($model->coordinates)); } } }