private function LeafletGeojson::leafletGeojsonMapPaneRenderLayeredMap in Leaflet GeoJSON 8
Helper function to generate the map markup based on the pane config.
1 call to LeafletGeojson::leafletGeojsonMapPaneRenderLayeredMap()
- LeafletGeojson::build in src/
Plugin/ Block/ LeafletGeojson.php - Builds and returns the renderable array for this block plugin.
File
- src/
Plugin/ Block/ LeafletGeojson.php, line 295
Class
- LeafletGeojson
- Provides a 'Leaflet Geojson' Block.
Namespace
Drupal\leaflet_geojson\Plugin\BlockCode
private function leafletGeojsonMapPaneRenderLayeredMap() {
$conf = $this->configuration;
// Gather information about the leaflet base and data layers.
$map_base_info = leaflet_map_get_info($conf['map_settings']['base']);
$data_layers_info = [];
foreach ($conf['map_settings']['info']['data'] as $layer_idx => $layer_machine_name) {
$data_layers_info[$layer_idx] = leaflet_geojson_source_get_info($layer_machine_name);
}
// We are not currently supporting mixed bounding, i.e. if any one layer
// is not bounded, then all layers will be fetched non-bounded. This will
// have serious performance impact at large scale.
$all_bounded = TRUE;
foreach ($data_layers_info as $layer_idx => $layer_info) {
if (!isset($layer_info['bbox'])) {
$all_bounded = FALSE;
break;
}
}
$feature_layers = [];
if ($all_bounded) {
// Ensure the map center is non-empty for bbox.
if (empty($map_base_info['center'])) {
$map_base_info['center'] = [
'lon' => 0,
'lat' => 0,
];
}
}
else {
/* @TODO: non-bounded data fetch */
}
// Apply any overrides of natural center and zoom.
if (!empty($conf['map_settings']['override_zoom_center'])) {
if (!empty($conf['map_settings']['custom_zoom_center']['zoom'])) {
$map_base_info['settings']['zoom'] = $conf['map_settings']['custom_zoom_center']['zoom'];
$map_base_info['settings']['map_position_force'] = TRUE;
}
if (!empty($conf['map_settings']['custom_zoom_center']['center']['lat']) && !empty($conf['map_settings']['custom_zoom_center']['center']['lon'])) {
$map_base_info['settings']['center'] = [
'lat' => $conf['map_settings']['custom_zoom_center']['center']['lat'],
'lon' => $conf['map_settings']['custom_zoom_center']['center']['lon'],
];
}
}
// Allow other modules to alter the map data.
$this->moduleHandler
->alter('leaflet_geojson_map_pane', $map_base_info, $feature_layers);
$map_build = $this->leafletService
->leafletRenderMap($map_base_info, $feature_layers, $conf['map_settings']['height'] . $conf['map_settings']['height_unit']);
return $map_build;
}