Best solution for project in D7 using Address Field, Geocoder API, Geofield, Geolocation (w. Maps), Search API (Not Solr), Search facets, Search ranges and Search views

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
tecjam's picture

Hi everyone,

I'm looking for some guidance in regards to a current project i'm working on:

Details:

Display businesses for a certain city by using geo data, a proximity slider from a pre-defined center point (supplied by field in the entity, url or defined in the view) and predefined start radius (also defined in the view or by url) - closest distance to center point are displayed first - with distance to center point calculated.

Business Node Details:

It's a website where nodes are created for businesses - lets call them businessnodes. These have, amongst many other things, an addressfield and i use geocoder to create the geo data from that address. This works fine and geo data is saved for each businessnode on creation.

City Details:

I thought it may be easiest to create taxonomy terms for each city which holds the geo data for it. I've added an extra field which uses the geolocation module with google maps to grab the cities center point geo data. Please note that Businessnodes are not tagged with a cities taxonomy term as the search should be able to break out of the city and use proximity based on geo data and not city name.

Search and filter:

This is where I am stuck! I want to display businessnodes for a specific city (taxonomy term) based on their proximity within a predefined radius and show a proximity slider to be able to 'pan out' or 'pan in' of the map so to speak. A map must not be displayed in the results as I will also show a lot of different facet search filters so results can be filtered further.
I do not want to have to create a view for each city to define the geo data, but if possible maybe use the taxonomy page for that city to display results, or use a view that gets the taxonomy term and therefore it's geo data from the url. eg: example.com/city/athens (would grab taxonomy term 'athens' and use its defined geo data center point).

I am not sure which is the best way to achieve this.

I am currently not using apache solr, but I am using Search api and the Database Server type to create facet searches and filter based on other taxonomy terms used in the businessnode.

Now I am stuck on the search and filter using views, proximity and facets.
How do I get my results and the proximity slider? Is my initial implementation idea wrong?

Is this possible without any custom module, or will I have to create a module and if yes, where do I start?

Any help on this would be greatly appreciated. Of course I am more that willing to supply the end result and maybe even a 'guide' or 'how to' page to help people out in the future.

Thanks in advance.

Comments

Seems like there was no real

tecjam's picture

Many thanks for all your kind and helpful comment (lol)

Seems like there was no real way around an apache solr setup. Otherwise I got a massive overhead trying to grab data and sorting / filtering on distance from a given point afterwards.
I still calculate the distance on the fly for the view rather than coding and exposing a field in views.

It does work roughly as I explainds above. The cities are nodes with a geocoded field for geodata. The views url arg(1) is the city name (/country/city/category). I grab it and load the node from the name, grab the geofields and query the solr database to return all results in that category in a 30 mile radius from that geo-point. In my template I calculate the distance by using the haversine php formula.

The site only went live yesterday, so it's early days yet. But I'm sure to write a follow up how I did it to help someone along

Are you ironic or did you get help offline?

tinem's picture

@tecjam wrote: Many thanks for all your kind and helpful comment (lol)

Are you ironic or did you get help offline?

A link to your site would be nice, please?

Yes, I was being ironic [you

tecjam's picture

Yes, I was being ironic [you may also say moronic ;-) ].

It's unfortunate but I found posting in this group to be a giant waste of time, so I just had to get stuck in and try and get it done alone. This is why I am more than willing to share how it was done when I get the time to write it up.
I got no help offline and I worked on this project only by myself. I do not know any other drupal (or php / mysql) developers I could have asked for help.
A lot of contributed modules helped me get there, but I had to modify and customise them heavily to get it to work the way I wanted.

The site is in german only atm and i'm still bug-hunting & optimising. So far only 1 city has entries (139 added so far).

Here is the category view for restaurants: http://bit.ly/zXnnJm

Looking forward to a beefy

KrisBulman's picture

Looking forward to a beefy write-up and code snippets if you're up for it. This is the sort of thing that we could all actually learn from, and would be a good model for others to contribute a similar style of posts. After reading Thomas Turnbull's Mapping with Drupal, I found myself wishing there was one finite collection to look for well thought out code snippets for certain operations we could build on and improve.. (much like the useful code within the book) as there clearly is no single mapping module that can do it all.

I can empathize with your frustrations for sure, most highly customized drupal solutions are hacked out alone, I'm expecting that very few mapping projects have done what you have with drupal alone. Thanks for sharing.

Hello tecjam, did you ever

fehin's picture

Hello tecjam, did you ever figure this out?

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: