I know bdragon is working on something that will make this easier eventually, but I really want to do this part of my site and he's got to be tired of me bugging him about it by now. So I thought I'd see if anyone else had done this that could help me with it. :)

I have an area directory ( http://couleeregiononline.com/directory ) and each node has one or more locations on it. I want to have a filtered map view so people can enter criteria and have all the resulting entries show up on a map. Making a simple map view is easy but there are two things I don't know how to do:

1) Have all the locations in the node show up on the map. TBH, I haven't tried this. I just thought of it as I was typing this issue. So maybe it's easy to do? I don't know.

2) This one is why I created the issue. Alongside the map I want to have the titles of all the matching nodes and a copy of the map marker. If the user clicks the title, it should open the node itself. If they click on the map marker, it should zoom to and open the pop up of the co-responding marker on the map. I haven't the foggiest idea how to do this. If anyone could give me even a push in the right direction, I'd really appreciate it.

Thanks,

Michelle

Comments

kobnim’s picture

Hello,
I am also trying to do this:

Alongside the map I want to have the titles of all the matching nodes and a copy of the map marker. If the user clicks the title, it should open the node itself. If they click on the map marker, it should zoom to and open the pop up of the co-responding marker on the map. I haven't the foggiest idea how to do this. If anyone could give me even a push in the right direction, I'd really appreciate it.

Michelle, have you figured out how to do this? If so, could you share your approach?

Thanks,
Mindy

kobnim’s picture

Newbie question ...

To accomplish what Michelle describes above, is this a reasonable starting point:

Override the gmap theme hook:

function theme_gmap($element) {
...
}

with:

function mytheme_gmap($element) {
  $o = mytheme_gmap_map($element);
  $o .= mytheme_gmap_markerlist($element);
  return ($o);
}

where:

  1. mytheme_gmap_map($element) is essentially a clone of the original theme_gmap() theme hook, i.e. creates the map;
  2. and

  3. mytheme_gmap_markerlist($element) creates the list of marker titles and links.

Am I barking up the wrong tree? Any suggestions would be most appreciated!

michelle’s picture

I've just been waiting for bdragon to release mapadelic.

Michelle

kobnim’s picture

Thanks Michelle.
Any idea when mapadelic will be released? Do you know if this be an extension to gmap or a new module? Do you know where I might find a description of what it will contain? (Nothing useful came up when I googled "mapadelic").

If it's due out reasonably soon, then I'll put aside what I've been working on. Otherwise, I'll probably plow ahead.

For what it's worth, here is an overview of what I've been trying to implement:

Goal:
When the user clicks a link in the sidebar the appropriate marker is highlighted.

How:

  1. markerarray[]:

    As new markers are created, save them in markerarray[].

    (I believe the markers are created in marker.js.)
  2. sidebar_click():
    Create a javascript function sidebar_click(i) that simulates a click on the ith marker. The function calls GEvent.trigger(markerarray[i], "click");
  3. sidebar_html:

    As new markers are created, update the string containing the sidebar html.

    Each sidebar item includes a link which when clicked calls the function sidebar_click(i), where 'i' is the index of the corresponding marker in markerarray[]."

Unfortunately, as a relative newbie to both drupal and javascript, I seem to be stubbing my toe as I try to integrate this into gmap. If anyone wants to give me a few pointers (assuming it will be a while before mapadelic is released) that would be most appreciated!

Mindy

michelle’s picture

Unfortunately, I have no idea when it will be out. All my attempts to get an ETA out of him have failed and I don't want to ask anymore because I'm probably being aggravating. I don't have the skills to do this myself, knowing neither javascript nor the intricacies of mapping. So all I can do is work on other parts of my site and wait for this to be made available. It's frustrating, but I've got my hands full learning PHP and Drupal programming and adding javascript and mapping to that right now just is too much.

Michelle

summit’s picture

Subcribing, mapadelic..interesting.
greetings,
Martijn

bestknight’s picture

Subscribing

konsumer’s picture

Try this:


drupal_add_js(<<< EOF

$(function(){
  var map=Drupal.gmap.getMap('nodemap');
  var waitForMarker = function(id){
    var marker = map.vars.markers[id].marker;
    if (typeof(marker) != 'undefined'){
      GEvent.trigger(marker, 'click');
    }else{
      setTimeout(function(){waitForMarker(id);}, 1000);
    }
  }
  waitForMarker(0);
});

EOF
,'inline');

Set waitForMarker(0) to the number of the marker. So, for the second marker, it would be waitForMarker(1).

This waits for the marker to exist (checks every second), and if it does, clicks it.

My marker array looks like this:

$map['markers'] = array(
  array(
    'latitude' => $venue->location['latitude'],
    'longitude' => $venue->location['longitude'],
    'text' => '<div class="ginfo"><h2><a href="'.$venue->path.'">'.$venue->title.'</a></h2><p>'.$venue->location['street'].' '.$venue->location['additional'].'</p><p>'.$venue->location['city'].'</p></div>',
    'opts' => array(
      'title' => $venue->location['street'].' '.$venue->location['additional'],
    ),
  ),
);
mrgoltra’s picture

+

rooby’s picture

Status: Active » Closed (won't fix)

Drupal 5 is no longer supported.

If this issue affects drupal 6 or 7 please look for an existing issue for that version or else update this issue accordingly.