/** * Returns the layer data. * * @param int $id */ protected function getStyleData($arrIds) { $arrLocationsStyles = array(); $objLocationStyles = C4gMapLocstylesModel::findMultipleByIds($arrIds); if ($objLocationStyles == null) { \HttpResultHelper::NotFound(); } while ($objLocationStyles->next()) { $arrLocationsStyles[] = $this->prepareStyleData($objLocationStyles->row()); } return $arrLocationsStyles; }
protected function createGeoJsonResult($objLayer, $strPopupTable = "") { $arrGeoJson = array(); $popup_async = true; $popup_content = $strPopupTable . ":" . $objLayer->id; if ($objLayer->popupType == "text" && !$objLayer->popup_info && $objLayer->locstyle) { $locstyle = C4gMapLocstylesModel::findByPk($objLayer->locstyle); if ($locstyle->popup_info) { $popup_content = $locstyle->popup_info; $popup_async = false; } else { $popup_content = ''; $popup_async = false; } } switch ($objLayer->location_type) { case "single": $arrGeoJson = array('type' => 'Feature', 'geometry' => array('type' => 'Point', 'coordinates' => array(floatval($objLayer->loc_geox), floatval($objLayer->loc_geoy))), 'properties' => array('projection' => 'EPSG:4326', 'popup' => array('async' => $popup_async, 'content' => $popup_content, 'routing_link' => $objLayer->routing_to), 'tooltip' => $objLayer->tooltip, 'label' => $objLayer->loc_label)); break; case "geojson": // check if there is a file to load the content from if ($objLayer->data_file) { $objFile = \FilesModel::findByUuid($objLayer->data_file); $objLayer->data_file = $objFile ? TL_ROOT . '/' . $objFile->path : false; $data = file_exists($objLayer->data_file) ? file_get_contents($objLayer->data_file) : false; } // @TODO: URL resource? // use data_content if other method failed $data = $data ?: $objLayer->data_content; // check projection switch ($objLayer->data_projection) { case 'MERC': $projection = 'EPSG:3857'; break; case 'WGS84': default: $projection = 'EPSG:4326'; break; } if (strpos($data, "Feature") !== false) { $arrGeoJson = json_decode($data, true); $arrGeoJson['properties'] = array('popup' => array('async' => $popup_async, 'content' => $popup_content, 'routing_link' => $objLayer->routing_to), 'projection' => $projection, 'label' => $objLayer->loc_label); } else { // OL3 needs a feature or feature-collection $arrGeoJson = array('type' => 'Feature', 'geometry' => json_decode($data), 'properties' => array('popup' => array('async' => $popup_async, 'content' => $popup_content, 'routing_link' => $objLayer->routing_to), 'projection' => $projection, 'tooltip' => $objLayer->tooltip, 'label' => $objLayer->loc_label)); } break; } return $arrGeoJson; }