/**
  * Do the frontend integration generation.
  *
  * @return string
  */
 public function generate()
 {
     $this->mapProvider->handleAjaxRequest($this->getIdentifier());
     if (TL_MODE === 'BE') {
         $model = MapModel::findByPk($this->get('leaflet_map'));
         $template = $this->getTemplateFactory()->createBackendTemplate('be_wildcard');
         if ($model) {
             $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id;
             $template->set('wildcard', '### LEAFLET MAP ' . $model->title . ' ###');
             $template->set('title', $this->get('headline'));
             $template->set('id', $model->id);
             $template->set('link', $model->title);
             $template->set('href', $href);
         }
         return $template->parse();
     }
     return parent::generate();
 }
 /**
  * Do the frontend integration generation.
  *
  * @return string
  */
 public function generate()
 {
     $this->mapService->handleAjaxRequest($this->getIdentifier());
     if (TL_MODE === 'BE') {
         $model = MapModel::findByPK($this->leaflet_map);
         $template = new \BackendTemplate('be_wildcard');
         if ($model) {
             $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id;
             $template->wildcard = '### LEAFLET MAP ' . $model->title . ' ###';
             $template->title = $this->headline;
             $template->id = $model->id;
             $template->link = $model->title;
             $template->href = $href;
         }
         return $template->parse();
     }
     return parent::generate();
 }
 /**
  * Get all leaflet maps.
  *
  * @return array
  */
 public function getMaps()
 {
     $collection = MapModel::findAll();
     return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions();
 }
 /**
  * Build map layers.
  *
  * @param Map              $map    The map being built.
  * @param MapModel         $model  The map model.
  * @param DefinitionMapper $mapper Definition mapper.
  * @param Filter           $filter Optional request filter.
  *
  * @return void
  */
 private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, Filter $filter = null)
 {
     $collection = $model->findActiveLayers();
     if ($collection) {
         foreach ($collection as $layer) {
             if (!$layer->active) {
                 continue;
             }
             $layer = $mapper->handle($layer, $filter, null, $map);
             if ($layer instanceof Layer) {
                 $layer->addTo($map);
             }
         }
     }
 }
 /**
  * Get map model.
  *
  * @param int|string $mapId Model id or alias.
  *
  * @return MapModel
  *
  * @throws \InvalidArgumentException If no model is found.
  */
 public function getModel($mapId)
 {
     $model = MapModel::findByIdOrAlias($mapId);
     if ($model === null) {
         throw new \InvalidArgumentException(sprintf('Model "%s" not found', $mapId));
     }
     return $model;
 }