Using GMap to display location that is in a reference node?

pudge's picture

Hi,
I have another problem using Views together with GMap. Can someone shed some light onto this for me?

I want to show a google map of all of the "event" nodes I have. I
am using Views, Gmap, Location module to do this following the
tutorials I read.

The problem is, my "event" node does not contain it's own
location. Instead each node makes a 'node reference' via a select list to
a venue which contains the location. The reason I did
this is because many events share the same venue and I don't
want the user to have to map the same location multiple times. As
the result the, the map does not appear because it expects the
location information to be in the node I am displaying.

How do I get around this? I need to somehow access the venue location
data as part of the event node. I am not sure how to do that.

I tried to use node_reference_view module to create a special event view but only succeeded at displaying a title link from events to the venue node. I was not able to display the venue location information in the view I created. I am not sure if this is the right track to pursuit?

I have some data on my site that you can see what I am talking about. The only difference between these two pages are their View 'Style'.

Gmap view style
http://mysterymilonga.com/drupal6/tango_map

HTML list view style
http://mysterymilonga.com/drupal6/page_list

Thanks,

Wayne

Login to post comments

Relationships

jhedstrom's picture
jhedstrom - Wed, 2009-07-22 22:56

In order to display the events associated with a location, you'll need to add 2 relationships in the view:

The first will be to the referenced node (the option will read something like 'Content: {field label} (field_name)', and the second will be to the location (when you add the second, select the first relationship in the drop list titled 'Relationship').

You can then add the lat and long fields, using the 2nd relationship added above when prompted to select a relationship.

Then, in the gmap display settings you select those 2 fields to provide the lat and long.


Thanks!

pudge's picture
pudge - Thu, 2009-07-23 00:03

I got it working but it was really messy. I somehow used only the reference node 'Content: Reference'. I think the key was that the view name had to match the name of my CCK node field (in my case 'field_reference_venue'). Then I added the longitude and latitude and 'referenced venue' in the Relationship. Then I tried to set the lat and long field in the Gmap display setting after changing the Data Source to 'Choose latitude and longitude fields' but the lat and long selects were empty no matter what I tried.

I then tried several things and noticed suddenly those fields appeared. I don't know what did it. After selecting them the map showed up.

Has this ever happened to anyone?

jhedstrom, I am not sure how this differs from your method but I will try yours too. Thanks again.

Wayne


Can you give please an

Buffer2k - Wed, 2009-09-16 18:25

Can you give please a detailed instruction how to do it? its very important for me! thank you!


empty drop-down

debain - Wed, 2009-08-26 13:59

Hi, I ve exactly the same problem. I changed the Data Source to 'Choose latitude and longitude fields' - but lat/lon field is an empty drop-down... I read some related articles but I can't figure out the problem. I installed the module nodelocation_relationship see documentation: http://drupal.org/node/468474 - but no luck...

EDIT:
I found the solution:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/gmap/gmap_p...