function geolocation_field_formatter_view in Geolocation Field 7
Implements hook_field_formatter_view().
File
- ./
geolocation.module, line 188 - A geolocation field using the Field API.
Code
function geolocation_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'geolocation_text':
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = '<p>' . t('Geolocation is @lat, @lng', array(
'@lat' => $item['lat'],
'@lng' => $item['lng'],
)) . '</p>';
}
break;
case 'geolocation_latlng':
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#theme' => 'geolocation_latlng',
'#lat' => $item['lat'],
'#lng' => $item['lng'],
);
}
break;
case 'geolocation_latitude':
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = $item['lat'];
}
break;
case 'geolocation_longitude':
foreach ($items as $delta => $item) {
$element[$delta]['#markup'] = $item['lng'];
}
break;
}
return $element;
}