GeolocationLatlngFormatter.php in Geolocation Field 8
File
src/Plugin/Field/FieldFormatter/GeolocationLatlngFormatter.php
View source
<?php
namespace Drupal\geolocation\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
class GeolocationLatlngFormatter extends FormatterBase {
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = [];
foreach ($items as $delta => $item) {
$element[$delta] = [
'#theme' => 'geolocation_latlng_formatter',
'#lat' => $item->lat,
'#lng' => $item->lng,
];
}
return $element;
}
}