public function ViewsEntityArgument::getCoordinates in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/geolocation/Location/ViewsEntityArgument.php \Drupal\geolocation\Plugin\geolocation\Location\ViewsEntityArgument::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/ ViewsEntityArgument.php, line 44
Class
- ViewsEntityArgument
- Derive center from proximity argument.
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);
}
/** @var \Drupal\geolocation\Plugin\views\argument\ProximityArgument $handler */
$handler = $displayHandler
->getHandler('argument', $location_option_id);
if (empty($handler)) {
return FALSE;
}
if ($values = $handler
->getParsedReferenceLocation()) {
if (isset($values['lat']) && isset($values['lng'])) {
return [
'lat' => $values['lat'],
'lng' => $values['lng'],
];
}
}
return parent::getCoordinates($location_option_id, $location_option_settings, $context);
}