If you want to use them, attached are theme override functions to make Gmap Views display a table or a list below a given view.

To apply them to your view, simply change the function name from phptemplate_views_view_gmap_volunteer_organizations_map2 to phptemplate_views_view_gmap_[your_view-name], then add them to the template.php for your site's theme. Leave the [your_view_name] part off entirely if you want either of them to apply for all Gmap Views that you create.

I tried to roll these into a theme style plugin for the module, but couldn't get it to work. Then I saw http://drupal.org/node/123601 and will investigate whether that patch provides the functionality I want.

This could be a good alternative, though, if you don't want to change the module, but just want to change how things work at the theming layer.

Comments

EvanDonovan’s picture

Sorry, the file didn't attach with either a php or a txt extension, so I'm just pasting it in here. This is my first bit of code to Drupal.org, so I'm still learning the ropes.

// Override volunteer_organizations_map2 view so that it displays a list as well as a map
function phptemplate_views_view_gmap_volunteer_organizations_map2($view, $results) {
  /* Two-step version: GMap + List
     Theme override by Evan Donovan - 6.6.08 */
     
 /* Stage 1: build the GMap */
 
	// Fields are used to render the markers.
  $fields = _views_get_fields();

  // find the ids of the column we want to use
  $point_ids = _gmap_views_find_coords_ids($view);

  if (isset($view->gmap_macro) && $view->gmap_macro) {
    $thismap = array(
      '#map' => 'view_gmap',
      '#settings' => array_merge(gmap_defaults(), gmap_parse_macro($view->gmap_macro)),
    );
    if ($thismap['#settings']['behavior']['views_autocenter']) {
      // Find the first valid location.
      foreach ($results as $entry) {
        $location = _gmap_views_get_lat_long_from_ids($entry, $point_ids);
        if (($location['lat']) && ($location['lon'])) {
          // Set default location for map
          $thismap['#settings']['latitude'] = $location['lat'];
          $thismap['#settings']['longitude'] = $location['lon'];
          // Break loop because we have what we want.
          break;
        }
      }
    }
  }
  else if (!empty($view->gmap_map)) {
    $thismap = $view->gmap_map;
  }
  else {
    $thismap = array(
      '#map' => 'view_gmap',
      '#settings' => gmap_defaults(),
    );
  }

  $fatmarkers = (isset($thismap['#settings']['behavior']['fatmarkers']) && $thismap['#settings']['behavior']['fatmarkers']);

  $markers = array();

  if ($fatmarkers) {
    $thismap['#settings']['viewfields'] = $view->field;
    $datafields = array();
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== FALSE) {
        $datafields[] = $field['queryname'];
      }
    }
  }

  $markermode = $thismap['#settings']['markermode'];
  $markertypes = variable_get('gmap_node_markers', array());

  foreach ($results as $entry) {
    $type = $entry->gmap_node_type;
    $location = _gmap_views_get_lat_long_from_ids($entry, $point_ids);

    if (($location['lat']) && ($location['lon'])) {
      if ($fatmarkers) {
        $data = array();
        foreach ($view->field as $field) {
          if ($fields[$field['id']]['visible'] !== FALSE) {
            $data[] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $entry, $view);
          }
        }
        $themarker = array(
          'markername' => isset($markertypes[$type]) ? $markertypes[$type] : 'drupal',
          'latitude' => $location['lat'],
          'longitude' => $location['lon'],
          'view' => array_values($data),
        );
        if (isset($entry->gmap_taxonomy_marker) && !empty($entry->gmap_taxonomy_marker)) {
          $themarker['markername'] = $entry->gmap_taxonomy_marker;
        }
      }
      else {
        // Common
        $themarker = array(
          'markername' => isset($markertypes[$type]) ? $markertypes[$type] : 'drupal',
          'latitude' => $location['lat'],
          'longitude' => $location['lon']
        );
        if (isset($entry->gmap_taxonomy_marker) && !empty($entry->gmap_taxonomy_marker)) {
          $themarker['markername'] = $entry->gmap_taxonomy_marker;
        }
        // Popup
        if ($markermode == 1) {
          $marker_tabs = theme('gmap_views_marker_label', $view, $fields, $entry);

          // add themed infoWindow HTML to either 'tabs' or 'text'
          if (is_array($marker_tabs)) {
              foreach ($marker_tabs as $tabi => $tabvalue) {
                  $marker_tabs[$tabi] = strtr($tabvalue, "'\n\r", '" ');
              }
              $themarker['tabs'] = $marker_tabs;
          }
          else {
              $themarker['text'] = strtr($marker_tabs, "'\n\r", '" ');
          }
        }
        // Link
        else if ($markermode == 2) {
          $themarker['link'] = url('node/'. $entry->nid);
        }
      }
      if (isset($entry->node_title)) {
        $themarker['opts']['title'] = $entry->node_title;
      }

      $markers[] = $themarker;
    }
  }
  $thismap['#settings']['markers'] = $markers;
  $output .= theme('gmap', $thismap);
  
  /* Stage 2: build the accompanying item list
     (code taken from theme_views_view_list - 
       cf. http://api.freestylesystems.co.uk/api/function/theme_views_view_list/5, http://drupal.org/node/42597) */
       
    foreach ($results as $node) {
    $item = '';
    foreach ($view->field as $field) {
      if (!isset($fields[$field['id']]['visible']) && $fields[$field['id']]['visible'] !== FALSE) {
        if ($field['label']) {
          $item .= "<div class='view-label ". views_css_safe('view-label-'. $field['queryname']) ."'>" . $field['label'] . "</div>";
        }
        $item .= "<div class='view-field ". views_css_safe('view-data-'. $field['queryname']) ."'>" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "</div>";
      }
    }
    $items[] = "<div class='view-item ". views_css_safe('view-item-'. $view->name) ."'>$item</div>\n"; // l($node->title, "node/$node->nid");
  }
    
  if ($items) { $output .= theme('item_list', $items); }
  return $output;
}

//Override volunteer_organizations_map view so that it displays a table as well as a Gmap
function phptemplate_views_view_gmap_volunteer_organizations_map($view, $results) {
  /* Two-step version: GMap + Table
     Theme override by Evan Donovan - 6.6.08 */
     
 /* Stage 1: build the GMap */
 
	// Fields are used to render the markers.
  $fields = _views_get_fields();

  // find the ids of the column we want to use
  $point_ids = _gmap_views_find_coords_ids($view);

  if (isset($view->gmap_macro) && $view->gmap_macro) {
    $thismap = array(
      '#map' => 'view_gmap',
      '#settings' => array_merge(gmap_defaults(), gmap_parse_macro($view->gmap_macro)),
    );
    if ($thismap['#settings']['behavior']['views_autocenter']) {
      // Find the first valid location.
      foreach ($results as $entry) {
        $location = _gmap_views_get_lat_long_from_ids($entry, $point_ids);
        if (($location['lat']) && ($location['lon'])) {
          // Set default location for map
          $thismap['#settings']['latitude'] = $location['lat'];
          $thismap['#settings']['longitude'] = $location['lon'];
          // Break loop because we have what we want.
          break;
        }
      }
    }
  }
  else if (!empty($view->gmap_map)) {
    $thismap = $view->gmap_map;
  }
  else {
    $thismap = array(
      '#map' => 'view_gmap',
      '#settings' => gmap_defaults(),
    );
  }

  $fatmarkers = (isset($thismap['#settings']['behavior']['fatmarkers']) && $thismap['#settings']['behavior']['fatmarkers']);

  $markers = array();

  if ($fatmarkers) {
    $thismap['#settings']['viewfields'] = $view->field;
    $datafields = array();
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== FALSE) {
        $datafields[] = $field['queryname'];
      }
    }
  }

  $markermode = $thismap['#settings']['markermode'];
  $markertypes = variable_get('gmap_node_markers', array());

  foreach ($results as $entry) {
    $type = $entry->gmap_node_type;
    $location = _gmap_views_get_lat_long_from_ids($entry, $point_ids);

    if (($location['lat']) && ($location['lon'])) {
      if ($fatmarkers) {
        $data = array();
        foreach ($view->field as $field) {
          if ($fields[$field['id']]['visible'] !== FALSE) {
            $data[] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $entry, $view);
          }
        }
        $themarker = array(
          'markername' => isset($markertypes[$type]) ? $markertypes[$type] : 'drupal',
          'latitude' => $location['lat'],
          'longitude' => $location['lon'],
          'view' => array_values($data),
        );
        if (isset($entry->gmap_taxonomy_marker) && !empty($entry->gmap_taxonomy_marker)) {
          $themarker['markername'] = $entry->gmap_taxonomy_marker;
        }
      }
      else {
        // Common
        $themarker = array(
          'markername' => isset($markertypes[$type]) ? $markertypes[$type] : 'drupal',
          'latitude' => $location['lat'],
          'longitude' => $location['lon']
        );
        if (isset($entry->gmap_taxonomy_marker) && !empty($entry->gmap_taxonomy_marker)) {
          $themarker['markername'] = $entry->gmap_taxonomy_marker;
        }
        // Popup
        if ($markermode == 1) {
          $marker_tabs = theme('gmap_views_marker_label', $view, $fields, $entry);

          // add themed infoWindow HTML to either 'tabs' or 'text'
          if (is_array($marker_tabs)) {
              foreach ($marker_tabs as $tabi => $tabvalue) {
                  $marker_tabs[$tabi] = strtr($tabvalue, "'\n\r", '" ');
              }
              $themarker['tabs'] = $marker_tabs;
          }
          else {
              $themarker['text'] = strtr($marker_tabs, "'\n\r", '" ');
          }
        }
        // Link
        else if ($markermode == 2) {
          $themarker['link'] = url('node/'. $entry->nid);
        }
      }
      if (isset($entry->node_title)) {
        $themarker['opts']['title'] = $entry->node_title;
      }

      $markers[] = $themarker;
    }
  }
  $thismap['#settings']['markers'] = $markers;
  $output .= theme('gmap', $thismap);
  
  /* Stage 2: build the accompanying table
     (code taken from theme_views_view_list - 
       cf. http://api.freestylesystems.co.uk/api/function/theme_views_view_list/5, http://drupal.org/node/42597) */
       
  foreach ($results as $node) {
    $row = array();
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== FALSE) {
        $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
        $cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']);
        $row[] = $cell;
      }
    }
    $rows[] = $row;
  }
    
  $output .= theme('table', $view->table_header, $rows);
  return $output;
}
summit’s picture

Hi,
Great post. Will this work for D6 also?
greetings,
Martijn

EvanDonovan’s picture

Not sure. I would recommend you check out #123601: Combine a gmap and any other views plugin, as that is a more versatile solution to this problem.

podarok’s picture

Status: Needs work » Closed (won't fix)

release unsupported
feel free to open issue against latest 7.x dev