Subissue of #1469956: [Meta] - Improve Views-powered Geofield proximity searches

We currently have 2 sets of views handlers to do proximity searches (found in 'views/handlers' and 'modules/geofield_proximity/views/handlers'). These really shouldn't be separate since they're basically doing the same thing, but with different input methods.

Part of the reason geofield_proximity is a separate submodule is detailed here (tl;dr - didn't want a geofield dependence on geocoder). We should be able to adjust our code to only display/use the geocoder-related stuff if geocoder is enabled, much like how we currently support OpenLayers.

Other stray observations:

  • I personally like the namespace of calling the handlers "Proximity" vs. "Distance from Point." More to the point.
  • We should use geofield_proximity's style of default labelling for handlers. jenlampton++
  • I've started some of this work based on a previous version of geofield_proximity, which can be found on the (poorly-named) 'views-integration' branch. This branch probably should be scrapped b/c of some overengineering in the filter handler, but it should provide a good overall guide of what a merge would look like.

Comments

Brandonian’s picture

Work is in progress on the proximity branch (checkout instructions at http://drupal.org/node/1087170/git-instructions/proximity). Work is more or less complete on the field handler, pending rigorous testing.

The filter handler will be the most complex of the 3 handlers (field, filter and sort) due to the handler's unique ability to be exposed to an end user. In an attempt to a) simplify views integration and b) make non-views powered distance filtering easier to build, we've created a custom FormAPI element (geofield_proximity) which takes 3 values, origin, distance and units (i.e., "[distance] [units] from [origin]." We'll use this element to handle passing data back and forth to the views handler.

Brandonian’s picture

StatusFileSize
new46.21 KB

Made some more progress on the filter. At this point, you can create a simple filter (i.e., not searching between 2 distances) with the geocoder option enabled. The filter also works as an exposed filter.

jimiobrien’s picture

Great work on this Brandonian. After installing the proximity branch I get a lot of "cannot redeclare" errors for geofield_proximity sub module, as they're already declared in the geofield main module, in the elements.inc. I'm assuming that since geofield_proximity is staying as a sub module the "geofield_proximity" functions in geofield.elements.inc are no longer required?
That is the roadmap isn't it. Keep proximity as a submodule?

Brandonian’s picture

@JimmyO, The opposite actually. geofield_proximity was originally built separately in order to ensure that geofield itself didn't need a hard requirement for geocoder, but the code I'm writing takes advantage of module_exists calls in order to ensure we don't accidentally use something from geocoder without it being present. You should be able to disable geofield_proximity.

giorgio79’s picture

Fantastic stuff, will be testing it now. Could we add an HTML5 Geolocation "Locate me" button next to the proximity fields? Most users would be interested in stuff near them.
The HTML5 Geolocation widget is already available for input, and having it as a filter would be great. Perhaps a button like this:
http://openlayers.org/dev/examples/geolocation.html Or should this be a separate filter?

WOW, I missed on the screenshot the geocode option, yeeehaa

1. Would be great to optionally set the geocode to auto prompt the user for their location when the page loads? Without them having to click on the Apply filter button?

2. Could we have the visible map view itself as a bounding box filter? Similar to Panoramio, or on my site at http://clipglobe.com I built a few years ago. If you zoom you can see the videos being repopulated depending on what is visible on the map.
PS Raising this 2nd question as a feature request for geo facet to integrate with http://drupal.org/project/facetapi

Brandonian’s picture

Status: Active » Fixed

Fixed. geofield_proximity is no longer a submodule, and it's functionality is superseded by geofield's proximity filters.

This happened over lots of different commits, just listing the removal of geofield_proximity.

http://drupalcode.org/project/geofield.git/commit/ec6ddad6fb7bb5d91f6c68...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

IWasBornToWin’s picture

I can't find any way to do any type of proximity search or to add anything with the word proximity in views. I've installed addressfield, geofield, and geocoder. I was about to install geolocation proximity but it said that was for geolocation not geofield. So how do I go about sorting and/or viewing distances between two locations?

Thanks