1

I am working on a project (Omega subtheme) with Panels and Views. I'm trying to create a list of local secondary schools and their distance from a few locations.

Installed Location Module, enabled it, together with Location Search, Location Taxonomy, Node Locations and Location CCK. Also, imported list of zipcodes for my location (gb) into database.

Next I created Content Type ‘secodnary school’ with School Location field, containing Address ,Postal Code, City, Country, and Latitude and Longitude fields.

Then I created 3 pieces of content – namely 3 local schools (to start with) with their addresses and lat/long info.

Finally, I tried to create a view that will contain the above list of secondary schools, sorted by their proximity to the given location and to connect it to a different piece of content (page) that holds the location info (address, postcode, latitude/longitude) of different (X,Y,Z) locations. X, Y, Z (…) are pieces of content (pages) of XYZ content type that among other things contain their individual location info.

So I need my new view (lets call it distance_sec_schools) to pick up location info from it’s host (XYZ) content (hint: I tried to configure CONTEXTUAL FILTER – content NID to provide content ID from URL – but it didn’t do the trick) and then provide me with the distances to 3 local schools, which I will then sort by proximity criteria.

Take a look at the screenshots of my view and Location: Distance / Proximity - Field Settings (framed red) and Filter (framed blude), which I suspect might be where my problem lies.

At the moment, my view produces a table with the school names but without the distances.

enter image description here

1 Answer 1

1

As far as I know it is not built into the location module but can easily be done in php with Haversine Formula, have a look here.

To add it to your view you can use Views PHP or theme a field with views-view-field--your-field.tpl.php passing in the two coordinates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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