Hello,

My very first issue submited so I hope it'll come out ok... here we go;

The project I am working in consists of a "march" around Catalunya (Spain), with prefixed events with their dates and locations.

I have installed and configured Gmap, GMap Location, GMap Macro Builder, GMap Views Integration, Location and Location Views properly, and currently have a map working on here: http://www.tempsdere-voltes.cat/activitats (note: I've also added a date CCK field for the event node type).

What I have right now allows me to add nodes of type event (activitat in catalan), and add a location in the Gmap. So far so good, and I truely thank all of you for this great module, but the next step would be to either add a line between the nodes markers or the route. Any suggestions as to how to go about geting drupal to do this?

I have read this http://drupal.org/node/209180 which does something very similar to what we need, only it works for defining a route for each node, we need to have a node for each stop in the route.

Hopefuly I am being clear enough... ow, and sorry for my english, I am not a native speaker :)

If you have any questions about the issue please do ask, I will try to respond as soon and clear as posible.

Thanks in advanced!

Comments

manuel garcia’s picture

Title: Auto route or line between nodes - How to? Is it posible? » I've been told this can't be done yet...

OK I have gotten some feedback in #drupal-suppot @ FreeNode, people say this feature is not available in gmap yet.

I went to the api documentation to see if this is "doable", and it seems the power is there for us to harness (*evil grin*), check out:
http://code.google.com/apis/maps/documentation/services.html#Driving_Dir...

Now as far as how in the world to implement this, I have no clue since i have not the necessary skills for this... Perhaps a brave programmer will take the challenge? It would surely be a great feature addition to the module!

tom_o_t’s picture

Title: I've been told this can't be done yet... » Lines on maps

I'd like to have this feature for a project I'm working on, but realistically I don't have the time to do this right now, nor do I have the skill to do it alone. But I'd happily help out with development if others are working on it too.

Cheers,

Thomas
http://www.greenmap.org

(PS - changed the Issue Title to reflect the topic)

manuel garcia’s picture

Title: Lines on maps » Auto route or line between nodes
Category: support » feature
manuel garcia’s picture

Title: Auto route or line between nodes » Lines on maps

Sorry tom_o_t ... i think we were adding comments at the same time.. switched title back.

And thanks for volunteering, hopefuly some other brave programmers will dare chiping in some time into this. :)

nicholasthompson’s picture

This feature would ROCK!

mdowsett’s picture

subscribing. this is exactly what I'm looking for...any progress in the past 8 months?

tom_o_t’s picture

No real progress on lines and shapes at Green Maps, but our summer intern is beginning to work on it now. We've done a bunch of custom modules that change much of the way content is viewed on our maps, so I don't know quite how useful this will be to anyone else.

Basically for lines & shapes we're making a module that will create a new CCK field that lets people draw lines & shapes on a GMap, then saves them in a table in the database that will use MySQL's basic spatial capabilities (http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html).

We probably won't code anything to integrate it with GMap Views as we're not using that. But perhaps it will be enough for someone to take forward. It's not ready yet, but hopefully there'll be something to show in a week or so.

mdowsett’s picture

maybe this is more of a location module feature request...I was thinking more along the line of allowing a node author to define multiple location points and once it is put on a map, a line is simply drawn between the lines.

Of course make it a check-box option to draw the lines or not...or even join the first and last locations to complete a shape...

manuel garcia’s picture

A good idea would be to have the option to auto draw the lines between nodes that have numbered icons, for example, to describe routes.
I bet this would be a widely used function in a lot of situations, and would make the map clearer for the user to read.

nchase’s picture

sounds great, this would realy rock :) ... Does someone know if there are intentions to have this in the verson for Drupal 6?

manuel garcia’s picture

Version: 5.x-1.0-alpha1 » 6.x-1.x-dev
sagannotcarl’s picture

Component: Miscellaneous » Code

Has anyone made progress on this issue?

I also want to reiterate what the original issue stated (since it's the same thing I'm looking for and it might have gotten a little lost along the way):
* Use location cck
* View that shows multiple nodes, each with a single location
* Line between the nodes on the map

The only addition I would have to spec this out is that the order that the line follows should follow the sort order (first node returned from the view is the start point, the second node would be the next stop, etc.).

If some admin interface work would be helpful for anyone I'd be happy to help.

sagannotcarl’s picture

So after getting a tip from bec on the right direction, here is how I've implemented what I outlined in #12.

* In a custom module call hook_gmap()
* Look at the markers
* Create a line with points at each marker in order

if you want to only add the lines to a certain map, set the map id (I did that in the view, you can also do it in the parse_macro op). Replace MAP-ID below with your map id and MODULENAME with your module name.

If anyone has any suggestions on how this could integrate with the gmap module I'd be happy to give it a whirl.

/**
 * Implementation of hook_gmap()
 * @param $op
 *  'parse_macro'
 *  'pre_theme_map'
 *  'macro_multiple'
 *  'behaviors'
 */
function MODULENAME_gmap($op, &$map) {
  switch ($op) {  
    case 'pre_theme_map':
      
      if ($map['id'] == 'MAP-ID') {
        $line_array = array();
        if ($map['markers'] != NULL) {
          foreach ($map['markers'] as $key => $marker) {
            $line_array[$key] = array(
              0 => $marker['latitude'],
              1 => $marker['longitude']
            );
          }
        }
        
        $map['shapes'] = array(
          0 => array(
            'type' => 'line',
            'points' => $line_array
          )
        );
      }
  }
}
sagannotcarl’s picture

pbarnett’s picture

I was surprised to see this come up again!

Lines are a doddle using theme_gmap, though I guess the underlying data structure would work with either approach.

See http://tuktuk.charityrallies.org/teams/11434/blogs/map - and check out the prev/next arrows (powered by some minimal javascript)

I still don't have the popup sizes coming out right, though :-(

This was written for 5.x, but I'm happy to share the code...

mdowsett’s picture

has anyone tried the Geo Module to achieve this?

pacome’s picture

Hi pbarnett,

could you give some details on how you did that ?
I'm trying to do something similar (on 6.x), but I can't find a way to do it.
I would like display the travel of a node, using multiple location and line between them..

Do you have any advice ?

Regards
-p-

pbarnett’s picture

Here's a code snippet - $settings is the array passed to theme('gmap', array('#settings' => $settings));

        $attributes = cr_maps_marker_attributes($gid);
        $colour = $attributes['colour'];
        $style = $attributes['style'];
        $width = $attributes['width'];
        $lwidth = 1;
        $settings['shapes'][$gid]['type'] = 'line';
        $settings['shapes'][$gid]['style'] = array($colour, $lwidth, 50, null, null);
        $settings['shapes'][$gid]['points'] = array();
        foreach($blogs as $blog) {
          $lat = $blog['lat'];
          $lon = $blog['lon'];
          if ($lat > 0 and $lon > -10) {
            $settings['shapes'][$gid]['points'][] = array($lat,$lon);
          }
        }
pacome’s picture

thank you !
but... a basic question : where should I use that code ?
Do I use it as a macro ?

Regards
-p-

pbarnett’s picture

No, this was in a custom module... you can use lines in a GMap macro quite easily - see this link. (a D5 site, but the same applies)

snez’s picture

Hi pbarnett, could you please provide a print_r of the $settings variable or some source of documentation for this?

Thanks

pbarnett’s picture