5

I'm using Drupal 7 with Views 3 module and Location 3 module installed.

I have a content type that has a Location type field and I would like to build a view that given a latitude/longitude input and a maximum distance i have to retrieve all the nodes that are in this range. Is that possible with views or I have to build something by my own (in this case can you show me the way on how to implement it).

Thanks a lot for your help

Danilo

Resuming the question problem is the following:

I have a problem setting a View to show the closest nodes of another (I'm using last dev version of views and locations on drupal 7). So my scenario is the following: I have 2 differents node types (A and B) both with a location field. I want to build a view that given a node A (with a determinate location) a have to retreive all the nodes B in a distance of 2Km. So to do that I created a view with the following filters:

  1. Content: Type = B
  2. Location: Distance / Proximity, with the parameters
    • {origin:"node's lat/lon from views nid argument"}
    • {Node ID argument to use: (it doesnt allow me to select any data)}
    • {Location to use:"CCK Location: field_A_loc"}.

I also added a contextual filter. I selected as contextual filter:

  • {Content: Nid}

and I added % to my path so now the pat is /myviewpath/%. This allow me to choose the value:

  • {Content: Nid} in the field "Node ID argument to use" of the filter "Location: Distance / Proximity".

So i try to run the view but I get no results when the view is called as mydomain.com/myviewpath/3 where 3 is a A node.

I also tried to do not use the contextual filter (that does not allow me to set the "Node ID argument to use" in the "Location: Distance / Proximity, with the parameters" filter) and running the view mydomain.com/myviewpath/node/3 but in this case I get the list of all B nodes..

What I'm doing wrong setting up this view??

Thanks in advance for your help

1

Yes, you could set up a view, filtering on Location: Distance / Proximity, and configure what the origin or "starting point" is, eg, the location of the logged in user, a node that has a location, or, in this case, a static lat/long, and then have it display whatever fields in the filtered nodes you want.

| improve this answer | |
  • Distance / Proximity are available as filters for Views with Location 3 installed? – Citricguy Dec 14 '11 at 3:33
  • Thanks jimajamma I setted the filter with Location: Distance / Proximity. But I dont have any contextual filter to set the lat/long dinamicaly. – ddelizia Dec 14 '11 at 8:50
  • If you need to dynamically set the origin lat/long, you can use the USE PHP TO DETERMINE LATITUDE/LONGITUDE option in the filter to create the coordinate anyway you want. – Jimajamma Dec 14 '11 at 14:35
  • Citricguy, yes, but it's not magic. you need to have set/entered a location for your users and/or nodes for it to have any effect. That's why there is a filter "Location ID" you can filter on "not empty" so you can filter out any users or nodes that haven't had it set. – Jimajamma Dec 14 '11 at 14:41
  • Thanks Jimajamma, if I have 2 different node types (A and B) both with a location filter. I want to build a view that given a node A (with a determinate location) a have to retreive all the nodes B in a distance of 2Km. I created a view with the following filters:(1) Content: Type = B (2) Location: Distance / Proximity, with the parameters{origin:"node's lat/lon from views nid argument"}{Node ID argument to use: (it doesnt allow me to select any data)}{Location to use:"CCK Location: field_A_loc"}. – ddelizia Dec 14 '11 at 22:12
0

Think the best docs are now up https://drupal.org/node/1944648

| improve this answer | |
0

By doing what you specified the view will show all nodes next to the visited node, as you added a contextual filter. Moreover, make sure to tick Exclude box in More section from {Content: Nid} field in contextual filter. This tutorial may be helpful https://www.reinisfischer.com/how-create-drupal-views-distance-filter-using-location-module

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.