I want to make a map displaying a line between all the nodes that share a certain taxonomy term.
The line would have to start at the node with the earliest publishing date and end at the latest node.

Does anyone have a suggestion to use views, macro-builder, or any other option I haven't thought about?

Support would be greatly appreciated!

Comments

TimDavies’s picture

I've just implemented a bit of a hacky way of getting a line drawn between pairs of nodes on a view with an edit to gmap.views.inc in the template_preprocess_gmap_view_gmap function.

The chunk between unset($vars['rows']); and $vars['map'] = is my addition and it takes the view results object, creates an array for each node id ($nid) and creates a point or each location found with that $nid.

You could, I imagine, re-purpose this so it creates a array for each taxonomy term ID retrieved from a views result object.

function template_preprocess_gmap_view_gmap(&$vars) {
  $vars['map_object'] = $vars['rows'];
  // Rows is actually our map object.
  unset($vars['rows']);

   $results = $vars['view']->result;

   foreach($results as $location) {
     $nid = $location->nid;
     $lines[$nid][] = array($location->gmap_lat,$location->gmap_lon);
   }

   foreach($lines as $line) {
     $shapes[] = array('type'=> 'line', 'style' => array('#00FF00',2,3),'points' => $line);
   }

   $vars['map_object']['shapes'] =  $shapes;

  // Theme the map.
  $vars['map'] = theme('gmap', array('#settings' => $vars['map_object']));
}

The code could (a) be a lot neater; and (b) probably be placed in a far better place as an add-on module with settings etc; but I just needed to get something working at 11pm last night and this the best I could come up with in the time...

johnv’s picture

Status: Active » Closed (won't fix)

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