GeolocationLatLngExportFormatter.php in REST Views 2.0.x
File
modules/rest_views_geo/src/Plugin/Field/FieldFormatter/GeolocationLatLngExportFormatter.php
View source
<?php
namespace Drupal\rest_views_geo\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\rest_views\SerializedData;
class GeolocationLatLngExportFormatter extends FormatterBase {
public function viewElements(FieldItemListInterface $items, $langcode) : array {
$elements = [];
foreach ($items as $delta => $item) {
$data = [
'lat' => $item->lat,
'lng' => $item->lng,
];
$elements[$delta] = [
'#type' => 'data',
'#data' => SerializedData::create($data),
];
}
return $elements;
}
}