You are here

function geofield_ymap_items_to_geojson in Geofield Yandex Maps 7

Convert field items to GeoJSON array.

2 calls to geofield_ymap_items_to_geojson()
geofield_ymap_field_formatter_view in ./geofield_ymap.formatter.inc
Implements hook_field_formatter_view().
geofield_ymap_field_widget_form in ./geofield_ymap.widget.inc
Implements hook_field_widget_form().

File

./geofield_ymap.module, line 114

Code

function geofield_ymap_items_to_geojson($items) {
  if (!$items) {
    return array();
  }
  geophp_load();
  $features = array();
  foreach ($items as $delte => $item) {
    if (!empty($item['geom'])) {
      $geoms = geoPHP::load($item['geom']);
      foreach (geofield_ymap_split_objects($geoms) as $geom) {
        $features[] = array(
          'type' => 'Feature',
          'geometry' => $geom
            ->out('json', TRUE),
        );
      }
    }
  }
  return $features ? array(
    'type' => 'FeatureCollection',
    'features' => $features,
  ) : array();
}