public function Location::getCoordinates in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/geolocation/LocationInput/Location.php \Drupal\geolocation\Plugin\geolocation\LocationInput\Location::getCoordinates()
Get center value.
Parameters
mixed $form_value: Form value.
int $center_option_id: LocationInput option ID.
array $center_option_settings: The current feature settings.
mixed $context: Context like field formatter, field widget or view.
Return value
array Render array.
Overrides LocationInputBase::getCoordinates
File
- src/
Plugin/ geolocation/ LocationInput/ Location.php, line 112
Class
- Location
- Location based proximity center.
Namespace
Drupal\geolocation\Plugin\geolocation\LocationInputCode
public function getCoordinates($form_value, $center_option_id, array $center_option_settings, $context = NULL) {
$values = explode(':', $center_option_id);
if (count($values) !== 2) {
return [];
}
$location_plugin_id = $values[0];
$location_option_id = $values[1];
if (!$this->locationManager
->hasDefinition($location_plugin_id)) {
return [];
}
/** @var \Drupal\geolocation\LocationInterface $location */
$location = $this->locationManager
->createInstance($location_plugin_id);
$center = $location
->getCoordinates($location_option_id, $center_option_settings['location_settings']['settings'], $context);
if (empty($center)) {
return FALSE;
}
return $center;
}