GeolocationField.php in Geolocation Field 8.3
File
src/Plugin/views/field/GeolocationField.php
View source
<?php
namespace Drupal\geolocation\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\EntityField;
use Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem;
class GeolocationField extends EntityField {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
unset($form['click_sort_column']);
}
protected function documentSelfTokens(&$tokens) {
parent::documentSelfTokens($tokens);
$tokens['{{ ' . $this->options['id'] . '__lat_sex }}'] = $this
->t('Latitude in sexagesimal notation.');
$tokens['{{ ' . $this->options['id'] . '__lng_sex }}'] = $this
->t('Longitude in sexagesimal notation.');
}
protected function addSelfTokens(&$tokens, $item) {
parent::addSelfTokens($tokens, $item);
if (empty($item['raw'])) {
return;
}
$geolocationItem = $item['raw'];
if ($geolocationItem
->isEmpty()) {
return;
}
$tokens['{{ ' . $this->options['id'] . '__lat_sex }}'] = GeolocationItem::decimalToSexagesimal($geolocationItem
->get('lat')
->getValue());
$tokens['{{ ' . $this->options['id'] . '__lng_sex }}'] = GeolocationItem::decimalToSexagesimal($geolocationItem
->get('lng')
->getValue());
}
}