You are here

function gmap_location_author_block_view in GMap Module 6.2

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

File

./gmap_location.module, line 710
GMap Location module is a module to add some gmap funcationality based on location.modules information.

Code

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()))) {
    $markername = variable_get('gmap_location_author_block_marker', 'drupal');
    $author = user_load(array(
      'uid' => $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($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
    }
  }
  return $block;
}