/**
  * Load the data.
  *
  * @param string $type   The data type.
  * @param mixed  $dataId The data id.
  * @param Filter $filter Optional request filter.
  *
  * @return array
  */
 public function loadData($type, $dataId, Filter $filter = null)
 {
     $error = false;
     $data = null;
     switch ($type) {
         case 'layer':
             $data = $this->mapProvider->getFeatureCollection($dataId, $filter);
             break;
         default:
             $error = true;
             return array($data, $error);
     }
     return array($data, $error);
 }
 /**
  * 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;
     }
 }