public function LocationInputBase::getCoordinates in Geolocation Field 8.3
Same name and namespace in other branches
- 8.2 src/LocationInputBase.php \Drupal\geolocation\LocationInputBase::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 LocationInputInterface::getCoordinates
1 call to LocationInputBase::getCoordinates()
- Geocoder::getCoordinates in src/
Plugin/ geolocation/ LocationInput/ Geocoder.php - Get center value.
2 methods override LocationInputBase::getCoordinates()
- Geocoder::getCoordinates in src/
Plugin/ geolocation/ LocationInput/ Geocoder.php - Get center value.
- Location::getCoordinates in src/
Plugin/ geolocation/ LocationInput/ Location.php - Get center value.
File
- src/
LocationInputBase.php, line 69
Class
- LocationInputBase
- Class LocationInputBase.
Namespace
Drupal\geolocationCode
public function getCoordinates($form_value, $option_id, array $option_settings, $context = NULL) {
if (empty($form_value['coordinates']) || !is_array($form_value['coordinates']) || !isset($form_value['coordinates']['lat']) || !isset($form_value['coordinates']['lng']) || $form_value['coordinates']['lng'] === '' || $form_value['coordinates']['lng'] === '') {
return FALSE;
}
return [
'lat' => (double) $form_value['coordinates']['lat'],
'lng' => (double) $form_value['coordinates']['lng'],
];
}