/**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     parent::build($definition, $model, $mapper, $filter, $parent);
     /** @var MarkerClusterGroup $definition */
     if ($model->iconCreateFunction) {
         $definition->setIconCreateFunction(new Expression($model->iconCreateFunction));
     }
     if ($model->polygonOptions) {
         $definition->setPolygonOptions((array) json_decode($model->polygonOptions, true));
     }
     if (!$model->disableDefaultStyle) {
         $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css||static';
     }
     $collection = LayerModel::findBy(array('pid=?', 'active=1'), array($model->id), array('order' => 'sorting'));
     if ($collection) {
         foreach ($collection as $layerModel) {
             $layer = $mapper->handle($layerModel);
             if ($layer instanceof Layer) {
                 $definition->addLayer($layer);
                 if ($layer instanceof OmnivoreLayer) {
                     $callback = new AnonymousFunction();
                     $callback->addLine('layers.' . $definition->getId() . '.addLayers(this.getLayers())');
                     $layer->on('ready', $callback);
                 }
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     parent::build($definition, $model, $mapper, $filter, $parent);
     /** @var TileLayer $definition */
     $filter = deserialize($model->bounds);
     if ($filter[0] && $filter[1]) {
         $filter = array_map(function ($value) {
             return explode(',', $value, 3);
         }, $filter);
         $filter = LatLngBounds::fromArray($filter);
         $definition->setBounds($filter);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     parent::build($definition, $model, $mapper, $filter);
     if ($definition instanceof OmnivoreLayer) {
         $metaModel = Factory::byId($model->metamodel);
         $items = $this->getItems($metaModel, $model, $filter);
         if (!$items->getCount()) {
             return;
         }
         /** @var GeoJson $layer */
         $layer = $definition->getCustomLayer();
         $collection = $layer->getInitializationData();
         $renderers = $this->getRenderers($model, $metaModel, $items, $mapper, $filter);
         if ($model->boundsMode) {
             $layer->setOption('boundsMode', $model->boundsMode);
         }
         foreach ($items as $item) {
             foreach ($renderers as $renderer) {
                 $renderer->loadData($item, $collection, $mapper, $definition->getId(), $filter);
                 $renderer->loadLayers($item, $layer, $mapper, $filter);
             }
         }
     }
 }