Hello,
I have a contenttype with locations (mostly lat/lon) and I would like to have a block that shows a list of nodes close to the node being viewed.
So imagine you are looking at /node/12 which is a content type with location enabled, that there is a block on that page with a list of the X closest nodes to that node 12.
On of the problems seem to be that I somehow have to get the nid of the node beeing seen into the block... I prefer to use the views (UI) instead of coding the block myself.
Thanks, Trogie
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | nodes_nearby_view.txt | 3.7 KB | rooby |
Comments
Comment #1
pwieck commentedThis is the same thing I am looking for except just embedded in the node, but I will take a block if takes all we can get.
Comment #2
yesct commentedI would like to see if anyone got this working too.
Comment #3
rooby commentedYou will need to use at least version 3.1 for this.
Attached is an export of an example view that does this. You can use that as a starting point. It is very basic but it has the parts you need for this functionality:
* nid argument that provides a default argument of "Node ID from URL" and has the "Exclude the argument" option checked.
* A location proximity filter that uses "Node's Latitude / Longitude from views nid argument" for the origin and uses the argument I previously mentioned for the "Node ID argument to use: " option.
Comment #4
rooby commentedMarked #435126: proximity search on current node, as a block, by passing lat long arguments as a duplicate of this issue.
Comment #5
rooby commentedMarked #446888: How to create a view that lists the closest nodes (within a certain radius)? as duplicate of this.
Comment #6
rooby commentedMarked #990304: Create a "near-by places" block as duplicate of this issue.
Comment #7
rooby commentedI have added instructions for this to the location handbook here - http://drupal.org/node/1038082
An export of my example view will also be uploaded to that page soon by a d.o webmaster as I don't have access to do so.
Comment #8
zdean commentedThe instructions in the handbook seem to work for listing either nearby nodes or the current node (based on the setting in the argument), but not both. Is it possible to show both in the same map and have different colored markers to distinguish the two?
thanks!
Comment #9
zdean commentedAlso, in following those instructions, if the "Style" in the view is set to Gmap and the argument is set to "Exclude the argument" (so that nearby nodes will be displayed), the map doesn't have anything to center on. It just shows the default macro map location.
Comment #10
rooby commentedThis is the part of the how to that explains excluding the argument:
Centering on the argument is out of the scope of that how to becaue it is a gmap feature and that is a location how to.
As I get time I will be adding more how tos for the location and gmap. At least one of the gmap ones will go over centering on/highlighting a marker.
Comment #11
zdean commentedThanks for clarifying the centering issue.
If I check "Exclude the argument" I get nearby nodes but not the current node. If I leave it unchecked, I get the current node but not nearby nodes. Any idea why I can't have both the current and the nearby nodes in the same result set when I leave it unchecked?
Comment #12
rooby commentedOh whoops, I forgot about that. Thanks for bringing it to my attention.
I'll update that how to.
To get all nodes, instead of using the 'Node: Nid' argument, use the 'Global: Null' argument.
It should still have all the same settings as you used for the Node: Nid one, except without the option to exclude the argument.
Comment #13
rooby commentedI have modified the how to a bit to fix information regarding including the current node in the view results.
Comment #14
zdean commentedThat works great. Thanks!
I'll poke around gmap and see if I can find the solution to the centering issue...that combined with your tutorial above would make for a fantastic tool (like Yelp, Citysearch, etc. where you can see similar locations near the current location flag on the map).
Comment #15
zdean commentedrooby...thanks for pointing me towards gmap for the solution. I was able to find it pretty quickly there. In the Gmap settings page, you simply select "autozoom" in the Map Behavior Flags section and then play with the default zoom levels til you get it just right.
Thanks again for the tutorial...huge help!
Comment #16
rooby commentedThere are actually views settings that the gmap module provides for that (if you are using gmap 1.1 or above I think).
In your view, where you select gmap for the style there will be a little gear image to the right where you get the gmap style options.
In there there are settings for:
* Center on node argument
* Highlight marker for node argument
That area also has a field named Macro, which can be used to set some settings for the gmap specifically for that view, like height, width, zoom etc.
So in that field you can have something like
[gmap zoom=5]
to set the zoom level to 5.
These settings should be a better solution than the autozoom option as they only affect that individual view.
For more information on gmap macros look at the GMAP-MACRO-DICTIONARY.txt file in the gmap module and maybe also try out the gmap macro builder module, which is included with the gmap module.
But anyway, that's a little off topic.
There are possibly some issues regarding these settings in the gmap issue queue too.
Comment #17
Anonymous (not verified) commentedThe handbook is awesome, thank you very much.
I have a question : Is it possible to display the current node location and the nearest nodes on the same map ? The current node would have a different marker, much bigger or another color.
Thank you !
Comment #18
rooby commentedYep, see my conversation with zdean in this issue, comments #11 - #16
Comment #19
rooby commentedMarked #1050490: Current node location and the nearest nodes on the same map as duplicate of this issue.
Comment #20
Anonymous (not verified) commentedHello,
Sorry for the duplicate.
Now it works just fine. Thank you.
It will be be perfect if I find a way to display a bigger marker for the current node.
Gmap doesn't use the right marker color for the content type (Marker handling by content type doesn't work).
Well, I will ask on the gmap page...
Thanks again ! :)
Comment #21
rooby commentedNo worries.
Marker handling by content type should work but yeah, that is a gmap issue.