Hello,

I tried to add a gmap card in my nodes with the combination of gmap and location. I implemented a node api this way and it works fine :

function gmap_node_nodeapi(&$node, $op){
	if ($op == 'view'){
		if (isset ($node->locations)){
			// $info = array();
			$info = array (	
				'#settings' => array(
					'id' => 'auto1map',
					'latitude' => $node->locations[0]['latitude'],
					'longitude' => $node->locations[0]['longitude'],
					
				),
			);
			foreach ($node->locations as $location){
				$info['#settings']['markers'][] = array(
				'latitude' => $location['latitude'],
				'longitude' => $location['longitude'],
				'markername'=>'small gray');
				
			}

			$output = theme ('gmap', $info);
			$node->content['gmap']['#value'] = $output;
		}
	}
}

What do you think of this piece of code? I know thats there's still work to do in order to generise this features. Ideas are welcome.

Comments

As If’s picture

Typically the field will be called something like "field_location". But yes, this works.

johnv’s picture

Status: Active » Closed (won't fix)

Closing this very old issue. Please reopen if it is still valid.