public function ViewsProximityFilter::getCoordinates in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/geolocation/Location/ViewsProximityFilter.php \Drupal\geolocation\Plugin\geolocation\Location\ViewsProximityFilter::getCoordinates()
Get map location.
Parameters
int $location_option_id: Location option ID.
array $location_option_settings: The current feature settings.
mixed $context: Context like field formatter, field widget or view.
Return value
array With content 'lat' => latitude 'lng' => longitude
Overrides LocationBase::getCoordinates
File
- src/
Plugin/ geolocation/ Location/ ViewsProximityFilter.php, line 76
Class
- ViewsProximityFilter
- Derive center from proximity filter.
Namespace
Drupal\geolocation\Plugin\geolocation\LocationCode
public function getCoordinates($location_option_id, array $location_option_settings, $context = NULL) {
if (!($displayHandler = self::getViewsDisplayHandler($context))) {
return parent::getCoordinates($location_option_id, $location_option_settings, $context);
}
$filter = $displayHandler
->getHandler('filter', $location_option_id);
if (empty($filter)) {
return parent::getCoordinates($location_option_id, $location_option_settings, $context);
}
if (array_key_exists('lat', $filter->value) && array_key_exists('lng', $filter->value)) {
return [
'lat' => (double) $filter->value['lat'],
'lng' => (double) $filter->value['lng'],
];
}
return $this->locationInputManager
->getCoordinates($filter->value['center'], $filter->options['location_input'], $filter);
}