Index: gmap.module =================================================================== --- gmap.module (revision 263) +++ gmap.module (working copy) @@ -1231,3 +1231,58 @@ $output .= gmap_draw_map($thismap); return $output; } + +/** + * Implementation of hook_block() + */ +function gmap_block($op = 'list', $delta = 0, $edit = array()) { + if ($op == 'list') { + $blocks[0] = array('info' => t('Map legend block'), + 'weight' => 0, 'enabled' => 0, 'region' => 'right'); + return $blocks; + } + else if ($op == 'configure' && $delta == 0) { + + } + else if ($op == 'save' && $delta == 0) { + + } + else if ($op == 'view') { + switch($delta) { + case 0: + $block = array('subject' => t('Map legend'), + 'content' => gmap_block_legend()); + break; + } + return $block; + } +} + +/** + * Generate a legend based on the different markers shown on the created map + */ +function gmap_block_legend() { + $ntypes=node_get_types(); + foreach ($ntypes as $key => $value) { + if (variable_get('location_'. $key, 0)) { + if ($icon = variable_get('gmap_node_marker_'.$key, NULL)) { + $legend[] = array('type' => $value, 'markername' => $icon); + } + } + } + return theme('gmap_legend',$legend); +} + +/** + * Theme the legend + */ +function theme_gmap_legend($legend) { + global $base_url; + foreach ($legend as $item) { + if (file_exists(variable_get('gmap_markerfiles',drupal_get_path('module', 'gmap') .'/markers').'/'.$item['markername'].'.png')) { + $marker=$base_url.'/'.variable_get('gmap_markerfiles',drupal_get_path('module', 'gmap') .'/markers').'/'.$item['markername'].'.png'; + } + $items[] = '