public function openlayers_views_plugin_map_views::render in Openlayers 7.3
Render the display in this style.
Overrides openlayers_views_plugin_style_source_vector::render
File
- modules/
openlayers_views/ views/ openlayers_views_plugin_map_views.inc, line 52 - Style handler that creates a map based on a view.
Class
- openlayers_views_plugin_map_views
- Class openlayers_views_plugin_map_views.
Code
public function render() {
$output = NULL;
$style_plugin_options = $this->view->style_plugin->options;
list($mapname, $layername) = explode(':', $style_plugin_options['base_map_layer'], 2);
if (empty($this->view->style_plugin->options['skipMapRender'])) {
/** @var \Drupal\openlayers\Types\MapInterface $map */
if (($map = \Drupal\openlayers\Openlayers::load('Map', $mapname)) == TRUE && !$map instanceof \Drupal\openlayers\Types\Error) {
/** @var \Drupal\openlayers\Types\LayerInterface $layer */
if ($layer = $map
->getCollection()
->getObjectById('layer', $layername)) {
$source = \Drupal\openlayers\Openlayers::load('source', 'openlayers_views_source_' . $this->view->name . '_' . $this->view->current_display);
$map
->addLayer($layer
->setSource($source));
}
$output = array(
'#type' => 'openlayers',
'#map' => $map,
);
}
}
else {
$grouped_results = $this
->render_grouping($this->view->result, $this->options['grouping']);
$output = $this
->map_features($grouped_results);
}
return $output;
}