Ejemplo n.º 1
0
 /**
  * Do the frontend integration compiling.
  *
  * @return void
  *
  * @throws \Exception If the map could not be created.
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 protected function compile()
 {
     try {
         $template = $this->leaflet_template ?: 'leaflet_map_js';
         $mapId = $this->getIdentifier();
         $map = $this->mapService->generate($this->leaflet_map, null, $mapId, $template);
         $GLOBALS['TL_BODY'][] = '<script>' . $map . '</script>';
         $this->Template->mapId = $mapId;
         $style = '';
         $height = deserialize($this->leaflet_height, true);
         $width = deserialize($this->leaflet_width, true);
         if (!empty($width['value'])) {
             $style .= 'width:' . $width['value'] . $width['unit'] . ';';
         }
         if (!empty($height['value'])) {
             $style .= 'height:' . $height['value'] . $height['unit'] . ';';
         }
         $this->Template->mapStyle = $style;
     } catch (\Exception $e) {
         throw $e;
     }
 }