public function LeafletService::leafletProcessGeofield in Leaflet 2.0.x
Same name and namespace in other branches
- 8 src/LeafletService.php \Drupal\leaflet\LeafletService::leafletProcessGeofield()
- 2.1.x src/LeafletService.php \Drupal\leaflet\LeafletService::leafletProcessGeofield()
Convert a geofield into an array of map points.
The map points can then be fed into $this->leafletRenderMap().
Parameters
mixed $items: A single value or array of geo values, each as a string in any of the supported formats or as an array of $item elements, each with a $item['wkt'] field.
Return value
array The return array.
File
- src/
LeafletService.php, line 183
Class
- LeafletService
- Provides a LeafletService class.
Namespace
Drupal\leafletCode
public function leafletProcessGeofield($items = []) {
if (!is_array($items)) {
$items = [
$items,
];
}
$data = [];
foreach ($items as $item) {
// Auto-detect and parse the format (e.g. WKT, JSON etc).
/* @var \GeometryCollection $geom */
if (!($geom = $this->geoPhpWrapper
->load(isset($item['wkt']) ? $item['wkt'] : $item))) {
continue;
}
$data[] = $this
->leafletProcessGeometry($geom);
}
return $data;
}