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

Comments
Relationships
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!
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
Can you give please a detailed instruction how to do it? its very important for me! thank you!
empty drop-down
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...
Thank you
Thanks @jhedstrom - you've saved my life. I spent so so long trying combinations of relationships/arguments etc. In case anyone else is trying to work this out I'll spell it out.
I have an event content-type: lecture
I have location content-type: location
The lecture content-type has a node reference to the location. (when creating an event you choose which location it is at)
I'm trying to display the map of the location on the lecture page (using a panel - doesn't need to be a panel though). I need a view that takes the location from the location content type which is referred to and displays it on the lecture page.
To make this happen. I create a view (node type) and use a node-type filter choosing only lectures.
I Add a relationship: Content: Location (node reference)
I add a second relationship: Content: Location (field) - I give this relationship the relationship of Location.
I then add the fields Longitude and Latitude. I give both of these the second relationship.
Then on the settings for the gmap view I don't choose Node location, instead I choose the longitude and latitude fields which say Location: longitude and Location: latitude (because of the relationship).
OK - I've just read that back and I don't even understand what I've written. Just stick to @jhedstrom's instructions. I hope it's helpful to someone. I got it to work.
Mixing node relationship and core node type on same map?
Thanks to the thread, I was able to almost get where I want to be. I have two content types:
1) Conference
2) City highlights
City highlights are created independently, and associated in the conference type via node reference fields (obviously, multiple city highlights per conference).
I'm able to get the city highlights to all show on a map, even using taxonomy markers, which is awesome.
But I can't seem to figure out how to get the base node to show up as a marker as well, so I can show the location of the conference.
Possible?
a terrible and easy fix to display node with nodereference
I'm imagining you have a view with a single conference as the argument, and shows all the city highlights that are nodereference connected to that conference, so the conference itself is not part of the pattern?
The most horrible way I can think of to solve this would be to let the conference nodereference itself along with the city highlights. This would let you avoid any code or complex views. (unless nodereference doesn't like self-referencing, but I can't think why it wouldn't) (Or possibly switch from nodereference to a regional taxonomy, which seems like it could be an improvement if the city highlights are really based on location and not specific to a conference... if you have two conferences in downtown Seattle, will they both have the same set of highlights? Then both highlights and conferences have a term for their region, and you're done.)
Better, you can also write a module to edit the view's sql statement, adding a simple "AND" to the sql from the module_views_pre_execute hook, more or less like: http://echodittolabs.org/blog/2010/06/group-views
Does anyone know a better way to combine the results of two views?
Thanks for the speedy reply
Thanks for the speedy reply Stephen. Not sure the self-reference would work either? I had to set up a relationship of course, so the latitude and longitude fields use the "city highlights" relationship. And the gmap settings only let me pick one field for lat, and one for long. If I take away the relationship, I don't actually get the correct data at all.
I do like the idea of updating the SQL statement though - chalk that up to another new hook I've learned about. Thanks again Stephen - I'll give that a shot.
Cheers,
Andrew
D7?
i have the same problem but drupal 7, any suggestions?
I also have the same problem with d7.
Anything new?
subscribe
subscribe
Query Works, So Do other Displays, Not Map
I have a content type (say, event) that has an entity reference to a location type (venue) and the venue has the location data. When I recreate the steps outlined above - the two relationships for the view, setting the lat/long field relationships, outputting as decimal, and setting the gmap settings to read those fields - I get no results for the map.
HOWEVER, if I change the format to, say, table I can see the lat/long info I expect in decimal format.
Additionally, when I paste the query that Views generates into MySQL, I get the results back I expect. My attachment display also works fine. I just get no results for the map. Been struggling with this for a few hours.
Anyone else run into this strange case?
Steven C Jackson
Owner, Rooted Logics
http://rootedlogics.com