Skip to content
Snippets Groups Projects
Commit ec1c2fb2 authored by Brandon Bergren's avatar Brandon Bergren
Browse files

Fix several block issues.

* Allow multiple locations for users and nodes.
* Fix marker titles and give them sane values.
* Add offset to make markers with multiple images work as expected.
* Rewrite gmap_location_author_block_view() to work similar to gmap_location_block_view().
* Remove hardcoded 'gmap_location_authorblock' mapid to match the behavior of the node block. (Reassign it in the macro if you need it.)
parent 3af249cc
No related branches found
No related tags found
No related merge requests found
......@@ -667,9 +667,11 @@ function gmap_location_block_view($nid) {
if ($node->locations) {
$markertypes = variable_get('gmap_node_markers', array());
$markers = array();
$count = 0;
foreach ($node->locations as $loc) {
// @@@ Todo: Client side geocoding
if ($loc['latitude'] || $loc['longitude']) {
$count++;
$markername = isset($markertypes[$node->type]) ? $markertypes[$node->type] : 'drupal';
if (module_exists('gmap_taxonomy')) {
$t = db_result(db_query('SELECT marker FROM {gmap_taxonomy_node} WHERE vid = %d', $node->vid));
......@@ -678,10 +680,17 @@ function gmap_location_block_view($nid) {
}
}
$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),
);
}
}
......@@ -695,7 +704,7 @@ function gmap_location_block_view($nid) {
$map['longitude'] = $markers[0]['longitude'];
$map['markers'] = $markers;
$block['subject'] = t('Location');
$block['content'] = theme('gmap', array('#settings' => $map));
$block['content'] = theme('gmap', array('#settings' => $map)); // @@@ Better theme
}
}
return $block;
......@@ -705,32 +714,38 @@ function gmap_location_author_block_view($nid) {
$block = array();
$node = node_load($nid);
if (in_array($node->type, variable_get('gmap_location_author_block_types', array()))) {
$result = db_fetch_array(db_query("SELECT latitude, longitude FROM {location} l INNER JOIN {location_instance} i ON l.lid = i.lid WHERE i.uid = %d", $node->uid));
if (!$result) {
// Location not set at all.
return;
$markername = variable_get('gmap_location_author_block_marker', 'drupal');
$author = user_load($node->uid);
$markers = array();
$count = 0;
foreach ($author->locations as $loc) {
// @@@ Todo: Client side geocoding
if ($loc['latitude'] || $loc['longitude']) {
$count++;
}
$markertitle = $author->name;
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($result['latitude']) && empty($result['longitude'])) {
// Coordinates not set.
return;
if (!empty($markers)) {
$macro = variable_get('gmap_location_author_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('Author Location');
$block['content'] = theme('gmap', array('#settings' => $map)); // @@@ Better theme
}
$macro = variable_get('gmap_location_author_block_macro', '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]');
$map = array(
'#map' => 'gmap_location_authorblock',
'#settings' => gmap_parse_macro($macro),
);
$map['#settings']['markers'] = array();
$map['#settings']['markers'][] = array(
'latitude' => $result['latitude'],
'longitude' => $result['longitude'],
'markername' => variable_get('gmap_location_author_block_marker', 'drupal'),
'label' => check_plain($node->name),
);
$map['#settings']['latitude'] = $result['latitude'];
$map['#settings']['longitude'] = $result['longitude'];
$block['subject'] = t('Author Location');
$block['content'] = theme('gmap', $map);
}
return $block;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment