public function IpGeoLocPluginStyleLeaflet::fillOutLocationRegions in IP Geolocation Views & Maps 8
Pending doc.
1 call to IpGeoLocPluginStyleLeaflet::fillOutLocationRegions()
- IpGeoLocPluginStyleLeaflet::render in src/
Plugin/ views/ style/ IpGeoLocPluginStyleLeaflet.php - Transform the View result in a list of marker locations and render on map.
File
- src/
Plugin/ views/ style/ IpGeoLocPluginStyleLeaflet.php, line 1233
Class
- IpGeoLocPluginStyleLeaflet
- Views Style plugin extension for Leaflet (if enabled).
Namespace
Drupal\ip_geoloc\Plugin\views\styleCode
public function fillOutLocationRegions($locations) {
// When an AddressField or hierarchical vocabulary is used, this normally
// returns a single field name (as an array).
if (empty($this->options['cluster_differentiator']['cluster_differentiator_fields'])) {
return;
}
$region_fields = [];
foreach ($this->options['cluster_differentiator']['cluster_differentiator_fields'] as $region_fieldname) {
// @TODO get the $entity type change hard coding
$region_field = FieldStorageConfig::loadByName('node', $region_fieldname);
$region_fields[] = empty($region_field) ? $region_fieldname : $region_field;
}
if (empty($region_fields) || !reset($region_fields)) {
return;
}
foreach ($this->view->result as $key => $row) {
if (isset($locations[$key])) {
$level = 1;
foreach ($region_fields as $region_field) {
$region_values = $this->viewPluginStyle
->getViewResult($this, $region_field, $key);
$field_type = $region_field
->getType();
// If the region is multi-valued, use the last value. A particular
// case is a hierarchical region taxonomy. We want the smallest of the
// regions in the hierarchy.
$region = $field_type == 'addressfield' ? $region_values : end($region_values);
if (empty($region)) {
// Make sure region is a string, not 0 or FALSE.
$region = '';
}
$this
->fillOutLocationRegion($field_type, $locations[$key], $region, $level);
}
}
}
}