function _geofield_description_formatter in Geofield 7
Same name and namespace in other branches
- 7.2 geofield.formatters.inc \_geofield_description_formatter()
1 call to _geofield_description_formatter()
- geofield_field_formatter_view in ./
geofield.formatters.inc - Implements hook_field_formatter_view().
File
- ./
geofield.formatters.inc, line 398 - Drupal field formatter hooks and helper functions.
Code
function _geofield_description_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_description_formatter_text($info);
}
else {
$output = t('A collection of shapes');
$output .= '<ol>';
foreach ($geometry
->getComponents() as $component) {
$centroid = $component
->centroid();
$info = _geofield_formatter_get_info($component, $centroid, $settings['address']);
$output .= '<li>' . _geofield_description_formatter_text($info) . '</li>';
}
$output .= '</ol>';
return $output;
}
}