You are here

function _geofield_item_microdata_propertyvalue in Geofield 7.2

Function to return appropriate GeoCoordinates/GeoShape properties.

This is developing code, as an example. Output can be made available to the theme, as specific site may want to display or not data based on other factors.

1 call to _geofield_item_microdata_propertyvalue()
geofield_field_formatter_view in ./geofield.formatters.inc
Implements hook_field_formatter_view().

File

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

Code

function _geofield_item_microdata_propertyvalue($entity, $instance, $item) {
  $output = '';

  // If there is no microdata mapping for the field, return an empty string.
  if (isset($entity->microdata[$instance['field_name']])) {
    $microdata = $entity->microdata[$instance['field_name']];
  }
  else {
    return '';
  }
  if ($item['geo_type'] == 'point') {
    foreach (array(
      'lat',
      'lon',
    ) as $property) {
      $microdata[$property]['#attributes']['content'] = $item[$property];
      $output .= '<meta' . drupal_attributes($microdata[$property]['#attributes']) . ' />';
    }
  }
  else {
    $schemaorg_shape = geofield_schemaorg_shape($item);
    $microdata['schemaorg_shape']['#attributes']['content'] = $schemaorg_shape;
    $output .= '<meta' . drupal_attributes($microdata['schemaorg_shape']['#attributes']) . ' />';
  }
  return $output;
}