protected function LeafletMarker::renderLeafletMarkers in Leaflet 8
Same name and namespace in other branches
- 2.1.x modules/leaflet_views/src/Plugin/views/row/LeafletMarker.php \Drupal\leaflet_views\Plugin\views\row\LeafletMarker::renderLeafletMarkers()
- 2.0.x modules/leaflet_views/src/Plugin/views/row/LeafletMarker.php \Drupal\leaflet_views\Plugin\views\row\LeafletMarker::renderLeafletMarkers()
Converts the given list of geo data points into a list of leaflet markers.
Parameters
array $points: A list of geofield points from {@link \Drupal::service('leaflet.service')->leafletProcessGeofield()}.
\Drupal\views\ResultRow $row: The views result row.
Return value
array List of leaflet markers.
1 call to LeafletMarker::renderLeafletMarkers()
- LeafletMarker::render in modules/
leaflet_views/ src/ Plugin/ views/ row/ LeafletMarker.php - Render a row object. This usually passes through to a theme template of some form, but not always.
File
- modules/
leaflet_views/ src/ Plugin/ views/ row/ LeafletMarker.php, line 330
Class
- LeafletMarker
- Plugin which formats a row as a leaflet marker.
Namespace
Drupal\leaflet_views\Plugin\views\rowCode
protected function renderLeafletMarkers(array $points, ResultRow $row) {
// Render the entity with the selected view mode.
$popup_body = '';
if ($this->options['description_field'] === '#rendered_entity' && is_object($row->_entity)) {
$entity = $row->_entity;
$build = $this
->getEntityManager()
->getViewBuilder($entity
->getEntityTypeId())
->view($entity, $this->options['view_mode']);
$popup_body = $this->renderer
->renderPlain($build);
}
elseif ($this->options['description_field']) {
$popup_body = $this->view
->getStyle()
->getField($row->index, $this->options['description_field']);
}
$label = $this->view
->getStyle()
->getField($row->index, $this->options['name_field']);
foreach ($points as &$point) {
$point['popup'] = $popup_body;
$point['label'] = $label;
// Allow sub-classes to adjust the marker.
$this
->alterLeafletMarker($point, $row);
// Allow modules to adjust the marker.
\Drupal::moduleHandler()
->alter('leaflet_views_feature', $point, $row, $this);
}
return $points;
}