public function GeolocationItem::onChange in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/Field/FieldType/GeolocationItem.php \Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem::onChange()
- 8 src/Plugin/Field/FieldType/GeolocationItem.php \Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem::onChange()
Parameters
bool $notify: (optional) Whether to forward the notification to the parent. Defaults to TRUE. By passing FALSE, overrides of this method can re-use the logic of parent classes without triggering notification.
Overrides Map::onChange
File
- src/
Plugin/ Field/ FieldType/ GeolocationItem.php, line 174
Class
- GeolocationItem
- Plugin implementation of the 'geolocation' field type.
Namespace
Drupal\geolocation\Plugin\Field\FieldTypeCode
public function onChange($property_name, $notify = TRUE) {
parent::onChange($property_name, $notify);
// Update the calculated properties if lat or lng changed.
if (($property_name == 'lat' || $property_name == 'lng') && !$this
->isEmpty()) {
$this
->get('lat_sin')
->setValue(sin(deg2rad(trim($this
->get('lat')
->getValue()))), FALSE);
$this
->get('lat_cos')
->setValue(cos(deg2rad(trim($this
->get('lat')
->getValue()))), FALSE);
$this
->get('lng_rad')
->setValue(deg2rad(trim($this
->get('lng')
->getValue())), FALSE);
}
}