You are here

function _geofield_def_list_formatter in Geofield 7

Same name and namespace in other branches
  1. 7.2 geofield.formatters.inc \_geofield_def_list_formatter()
1 call to _geofield_def_list_formatter()
geofield_field_formatter_view in ./geofield.formatters.inc
Implements hook_field_formatter_view().

File

./geofield.formatters.inc, line 363
Drupal field formatter hooks and helper functions.

Code

function _geofield_def_list_formatter($item, $settings) {
  geophp_load();
  $geometry = geoPHP::load($item['wkt'], 'wkt');

  // Single types
  $single_types = array(
    'Point',
    'LineString',
    'Polygon',
  );
  if (in_array($geometry
    ->geometryType(), $single_types)) {
    $centroid = new Point($item['lon'], $item['lat']);
    $info = _geofield_formatter_get_info($geometry, $centroid, $settings['address']);
    return _geofield_def_list_formatter_dl($info);
  }
  else {
    $output = '';
    foreach ($geometry
      ->getComponents() as $component) {
      $centroid = $component
        ->centroid();
      $info = _geofield_formatter_get_info($component, $centroid, $settings['address']);
      $output .= _geofield_def_list_formatter_dl($info);
    }
    return $output;
  }
}