I think it would be good if the Gmap module provided a tab by default that showed the GMap for Location-enabled nodes. I have accomplished this by adding the following code to gmap.module. My apologies for the lack of patch - I need to find a way to make patches more easily or else I just don't get around to doing them in the middle of the work day.

Anyway, I added this code to the gmap_menu():

  	$items['node/%node/map'] = array(
    'title' => 'Map',
    'page callback' => 'gmap_node_map',
    'page arguments' => array(1),
	'access callback' => 'gmap_node_map_access',
	'access arguments' => array(1),
    'weight' => 2,
    'type' => MENU_LOCAL_TASK
  ); 

And here's the page & access callbacks:

/* Page callback for node map tab */
function gmap_node_map(&$node) {
	if($node->location['latitude'] && $node->location['longitude']) {
			drupal_set_title(t('Map: ') . check_plain($node->title));
				$marker_words = "<h2>" . check_plain($node->field_volopp_org_name[0]['view']) . "</h2>";
				$macro = "[id=map1 |center=" . $node->location['latitude'] . ", " . $node->location['longitude'] . " | markers=" . $node->location['latitude'] . ", " . $node->location['longitude'] . " | zoom=6 |width=300px |height=300px |align=None |control=Small |type=Map|tcontrol=on]";
				$map = theme('gmap', array('#settings' => gmap_parse_macro($macro)));
				$output = $map;
		  }
	else {
	$output = "Map not available.";
	}
	return $output;
}

/* Access callback for location_node_map() */
function gmap_node_map_access(&$node) {
	if($node->location && user_access('access content')) {
		return TRUE;
	}
	else {
		return FALSE;
	}
}

Comments

a.a.egoroff’s picture

Thanks! Works for me:)

thekayra’s picture

Combining CCK, Locations CCK and jQuery UI Tabs worked for me. Quite flexible I would say.

Only semi-serious problem that I had choose is the problem to show gMap in a hidden tab. A little search allowed me to find this solution (#3)

Kayra.

EvanDonovan’s picture

I realized after I posted this code that there is a conflict with Feed API, if you have that installed. I would recommend using the name 'Show Map' and the path '/show-map' since Feed API owns '/map'.

EvanDonovan’s picture

Status: Active » Closed (won't fix)

I think this would be better in a separate module (that's how I have it now).