function _gmap_location_block_view in GMap Module 7
Same name and namespace in other branches
- 7.2 gmap_location.module \_gmap_location_block_view()
1 call to _gmap_location_block_view()
- gmap_location_block_view in ./
gmap_location.module - Implement hook_block_view().
File
- ./
gmap_location.module, line 694 - GMap Location module is a module to add some gmap funcationality based on location.modules information.
Code
function _gmap_location_block_view($nid) {
$block = array();
$node = node_load($nid);
if (!empty($node->locations)) {
$markertypes = variable_get('gmap_node_markers', array());
$markers = array();
$count = 0;
foreach ($node->locations as $loc) {
// @@@ Todo: Client side geocoding
if (location_has_coordinates($loc)) {
$count++;
$markername = isset($markertypes[$node->type]) ? $markertypes[$node->type] : 'drupal';
if (module_exists('gmap_taxonomy')) {
$t = db_query('SELECT marker FROM {gmap_taxonomy_node} WHERE nid = :nid', array(
':nid' => $node->nid,
))
->fetchField();
if (!empty($t)) {
$markername = $t;
}
}
$markertitle = $node->title;
if (!empty($loc['name'])) {
$markertitle = $loc['name'];
}
$markers[] = array(
'latitude' => $loc['latitude'],
'longitude' => $loc['longitude'],
'markername' => $markername,
'offset' => $count - 1,
'opts' => array(
'title' => $markertitle,
),
);
}
}
if (!empty($markers)) {
$macro = variable_get('gmap_location_block_macro_' . $node->type, '');
if (empty($macro)) {
$macro = variable_get('gmap_location_block_macro', '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]');
}
$map = gmap_parse_macro($macro);
$map['latitude'] = $markers[0]['latitude'];
$map['longitude'] = $markers[0]['longitude'];
$map['markers'] = $markers;
$block['subject'] = t('Location');
$element = array(
'#type' => 'gmap',
'#gmap_settings' => $map,
);
$block['content'] = drupal_render($element);
// @@@ Better theme
}
}
return $block;
}