コード例 #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->get('leaflet_template') ?: 'leaflet_map_js';
         $mapId = $this->getIdentifier();
         $map = $this->mapProvider->generate($this->get('leaflet_map'), null, $mapId, $template);
         $this->template->set('javascript', $map);
         $this->template->set('mapId', $mapId);
         $style = '';
         $height = deserialize($this->get('leaflet_height'), true);
         $width = deserialize($this->get('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->set('mapStyle', $style);
     } catch (\Exception $e) {
         throw $e;
     }
 }