GeolocationSexagesimalFormatter.php in Geolocation Field 8
Same filename and directory in other branches
File
src/Plugin/Field/FieldFormatter/GeolocationSexagesimalFormatter.phpView source
<?php
namespace Drupal\geolocation\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\geolocation\GeolocationCore;
/**
* Plugin implementation of the 'geolocation_sexagesimal' formatter.
*
* @FieldFormatter(
* id = "geolocation_sexagesimal",
* module = "geolocation",
* label = @Translation("Geolocation Sexagesimal / GPS / DMS"),
* field_types = {
* "geolocation"
* }
* )
*/
class GeolocationSexagesimalFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = [];
foreach ($items as $delta => $item) {
$element[$delta] = [
'#theme' => 'geolocation_sexagesimal_formatter',
'#lat' => GeolocationCore::decimalToSexagesimal($item->lat),
'#lng' => GeolocationCore::decimalToSexagesimal($item->lng),
];
}
return $element;
}
}
Classes
Name | Description |
---|---|
GeolocationSexagesimalFormatter | Plugin implementation of the 'geolocation_sexagesimal' formatter. |