You are here

public function Geofield::getPositionsFromItem in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_geofield/src/Plugin/geolocation/DataProvider/Geofield.php \Drupal\geolocation_geofield\Plugin\geolocation\DataProvider\Geofield::getPositionsFromItem()

Get positions from field item list.

Parameters

\Drupal\Core\Field\FieldItemInterface $fieldItem: Views field definition.

Return value

array Retrieved locations.

Overrides DataProviderBase::getPositionsFromItem

File

modules/geolocation_geofield/src/Plugin/geolocation/DataProvider/Geofield.php, line 55

Class

Geofield
Provides Google Maps.

Namespace

Drupal\geolocation_geofield\Plugin\geolocation\DataProvider

Code

public function getPositionsFromItem(FieldItemInterface $fieldItem) {
  if ($fieldItem instanceof GeofieldItem) {
    return [
      'lat' => $fieldItem
        ->get('lat')
        ->getValue(),
      'lng' => $fieldItem
        ->get('lon')
        ->getValue(),
    ];
  }
  return FALSE;
}