You are here

function leaflet_field_formatter_view in Leaflet 7

Implements hook_field_formatter_view().

File

./leaflet.formatters.inc, line 146
Leaflet field formatter functions.

Code

function leaflet_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];
  if (count($items) == 0) {
    return '';
  }
  else {
    switch ($display['type']) {
      case 'geofield_leaflet':
        $map = leaflet_map_get_info($settings['leaflet_map']);
        $features = leaflet_process_geofield($items);
        foreach ($features as &$feat) {
          $feat['entity'] = $entity;
        }
        leaflet_apply_map_settings($map, $features, $settings, $entity_type);
        $element[0] = leaflet_build_map($map, $features, $settings['height'] . 'px');
        break;
    }
    return $element;
  }
}