You are here

function gmap_location_block_view in GMap Module 6.2

Same name and namespace in other branches
  1. 5 gmap_location.module \gmap_location_block_view()
  2. 6 gmap_location.module \gmap_location_block_view()
  3. 7.2 gmap_location.module \gmap_location_block_view()
  4. 7 gmap_location.module \gmap_location_block_view()
1 call to gmap_location_block_view()
gmap_location_block in ./gmap_location.module
Draw block of location for current node.

File

./gmap_location.module, line 661
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_result(db_query('SELECT marker FROM {gmap_taxonomy_node} WHERE vid = %d', $node->vid));
          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');
      $block['content'] = theme('gmap', array(
        '#settings' => $map,
      ));

      // @@@ Better theme
    }
  }
  return $block;
}