function _gmap_cck_noderef_markers in GMap Addons 5
Same name and namespace in other branches
- 6 gmap_cck.module \_gmap_cck_noderef_markers()
- 7 gmap_cck.module \_gmap_cck_noderef_markers()
load locations from nodes pointed at with noderef field, show markers
1 call to _gmap_cck_noderef_markers()
- gmap_cck_field_formatter in ./
gmap_cck.module - Prepare an individual item for viewing in a browser.
File
- ./
gmap_cck.module, line 512 - display of a google map as cck field
Code
function _gmap_cck_noderef_markers(&$settings, &$field, &$node) {
$fname = 'field_' . $field['marker_noderef'];
$nrf =& $node->{$fname};
$nids = array();
foreach ($nrf as $delta => $item) {
if (!empty($item['nid']) && is_numeric($item['nid'])) {
$nids[] = $item['nid'];
$n = node_load($item['nid']);
if ($n) {
$settings['markers'][] = array(
'label' => $n->title,
'opts' => array(
'title' => $n->title,
),
'latitude' => $n->locations[0]['latitude'],
'longitude' => $n->locations[0]['longitude'],
'markername' => variable_get('gmap_node_marker_' . $n->type, 'drupal'),
'text' => theme('gmapnodelabel', $n),
);
}
}
}
/* TODO: go this route if we have too many (how many?) nodes
if (count($nids)) {
$nidstr = implode(',', $nids);
//$res = db_query("SELECT * FROM {location} l , {node_revisions} nr WHERE".
// " l.type = 'node' AND l.eid = nr.vid AND nr.nid IN('$nidstr')");
$res = db_query("SELECT nr.title, n.nid, n.type, max(nr.vid) vid,".
" l.latitude, l.longitude FROM location l, node n, node_revisions nr".
" WHERE l.type = 'node' AND l.eid = nr.vid AND n.nid = nr.nid AND".
" nr.nid IN($nidstr) GROUP BY n.nid");
$locs = array();
while ($nl = db_fetch_object($res)) {
if (!isset($locs[$nl->nid]) || ($locs[$nl->nid]->timestamp < $nl->timestamp)) {
$locs[$nl->nid] = $nl;
}
}
foreach ($locs as $nid => $nl) {
$settings['markers'][] = array(
'label' => $nl->title,
'latitude' => $nl->latitude,
'longitude' => $nl->longitude,
'markername' => variable_get('gmap_node_marker_'. $nl->type, 'drupal'),
//'text' => theme('gmapnodelabel',$nl), // TODO:
'popuplink' => url('map/query/node/'. $nl->nid),
);
}
}
*/
}