function gmap_cck_field_formatter in GMap Addons 5
Same name and namespace in other branches
- 6 gmap_cck.module \gmap_cck_field_formatter()
- 7 gmap_cck.module \gmap_cck_field_formatter()
Prepare an individual item for viewing in a browser.
Parameters
$field: The field the action is being performed on.
$item: An array, keyed by column, of the data stored for this item in this field.
$formatter: The name of the formatter being used to display the field.
$node: The node object, for context. Will be NULL in some cases. Warning : when displaying field retrieved by Views, $node will not be a "full-fledged" node object, but an object containg the data returned by the Views query (at least nid, vid, changed)
Return value
An HTML string containing the formatted item.
In a multiple-value field scenario, this function will be called once per value currently stored in the field. This function is also used as the handler for viewing a field in a views.module tabular listing.
It is important that this function at the minimum perform security transformations such as running check_plain() or check_markup().
File
- ./
gmap_cck.module, line 264 - display of a google map as cck field
Code
function gmap_cck_field_formatter($field, $item, $formatter, $node) {
if (!isset($item['value'])) {
return '';
}
$m = unserialize($item['value']);
if (!is_array($m)) {
$m = array();
}
if (!empty($field['gpx']) && _gmap_cck_check_gpx_source($m, $field, $node)) {
_gmap_cck_get_gpx($m, $field, $node);
}
if (!empty($field['marker_noderef'])) {
_gmap_cck_noderef_markers($m, $field, $node);
}
$map = array_merge(gmap_defaults(), $field, $m);
$map['id'] = 'gmap';
if (isset($node) && isset($node->nid)) {
$map['id'] .= '_' . $node->nid;
}
$map['id'] .= '_' . $field['field_name'];
// TODO: correct width, height & zoom if ($formatter != 'default')
return theme('gmap', array(
'#settings' => $map,
));
}