I am trying to set it up so that a global filter can set the distance and city (location) for the proximity filter for Geofield. I essentially have several views that rely on setting the proximity to a user defined location and don't want them to have to set the distance and location (e.g. 25 kilometres from Victoria, BC) on each one as they browse the site. I have gone through the readme but I can't seem to wrap my head around how to make this happen. If you have anything that will point me in the right direction, I would be very appreciative.

Comments

RdeBoer’s picture

Hi Nico,
Thanks for your interest in Views Global Filter.
Yep I'm about to do the same thing. One thing for sure: use Geofield 7.x-2.0-xxxx as 7.x-1.x does not have the Views filter capabilities.

Are you just using a tabular View or is the end game to filter maps by proximity to an entered location or visitor location?
How is the location entered? Via postal address, lat/long or widget? If so, which one?

Rik

pixelsweatshop’s picture

Thanks for your quick response Rik. Loved your presentation at DrupalCon BTW.

I have a project very similar to https://foursquare.com but has nothing to do with users checking in. We are mapping events.

Essentially we are trying to replicate what an anonymous users sees when they first go to the foursquare landing page.

1. Just like Foursquare, user is presented with a popup where on enters the proximity distance and location (Geofield Proximity). Ideally we would like to use Smart IP to prepolulate the users location but Geofield has yet to implement this.

2. User then sees a combined map and list view (views and views attach to add the list to the map inheriting exposed filters). Exactly the same as foursquare.

3. The combined map and list view is then tabbed with Events grouped for Today, This week, This Month, This year

Just need the exposed geofield proximity filter to persist thorough each tab. This is where we are hoping views global filter can fit in nicely.

I am currently using

Addressfield
Geofield (Definitely 2.x)
Geocoder
OpenLayers (Was hoping for Leaflet but I it's missing a few UI features that I need. Still on the fence though)

RdeBoer’s picture

Hi Nico,

Which DrupalCon presentation?
The Sydney one? http://www.youtube.com/watch?v=iznuDhjAFbg
Or the Portland one? http://www.youtube.com/watch?v=BPXDrln0QB0&feature=youtu.be

Both might be relevant to you (the first one mentions Foursquare and has a demo of IP Geolocation Views and Maps with Views Global Filter, albeit in a different context to yours.

This site goes half way where you want to go I think: http://greatcalgaryfestivals.ca/ (scroll down for the map)

Also, are you aware of the "IP Geolocation Views and Maps" for mapping and how it features Location-Based Services HTML5 to locate the user with Smart IP as a backup?

Will you need location marker differentiation by content type, taxonomy or any field in your View? See this lovely site: http://stallspot.co.nz/discover

Rik

pixelsweatshop’s picture

It was the Portland one. It was nice to hear from all of the mapping gurus. :)

That Calgary one is a great example. One of yours?

We have been experimenting with ip geolocation views and maps. In fact I beleive you have been very helpful with one of my employees, nigel on that front. It looks like this module will get us most of the way there but we just can't seem to combine the map and list view, then have the global filter carry across the tabbed view for "today", "this week" etc.

We are currently experimenting with all of the geospatial tools right now to see what we can leverage for this project. We just can't seem to piece the modules together to get essentially a foursquare clone.

We will also need marker diff based on taxonomy term.

pixelsweatshop’s picture

Nigel has now shown me the capabilities of IP Geolocation and Views. I am impressed. Well done, sir. It looks like we will be moving in that direction. So we just need to figure out how to leverage ip_geoloc, global filter to prepoulate geofield proximity.

RdeBoer’s picture

Hi Nico,

Thanks! And more goodies coming in IPGV&M....
No I didn't personally do the Calgary site, but gave the site builder a few hints, in particular w.r.t to the animated marker clustering.

I'll set up a test rig as I've been wanting to use Views Global Filter with Geofield 7.x-2.x for a while myself.
I'll make an estimate of the work involved, so I can plan next steps.

This may involve patches/extensions on the Geofield as well as on the Gloal Filter sides.

I was in the panel presentation with Brandonian the current maintainer of Geofield, so hopefully between all of us we can push this on through.

Rik

RdeBoer’s picture

Title: Using views global filter with geofield 2x proximity » Using views global filter with Geofield 7.x-2.x proximity

Sooo.... after closer inspection... the first issue is that Geofield 7.x-2.x does not feature a Views contextual filter for proximity -- it only has a "normal" UI filter.

We need Geofield to expose a Views contextual filter for Views Global Filter to do its thing.

So we need to either submit a feature request with the maintainer of the Geofield module or submit a patch to him.

Then we can create a Views Global Filter option for global proximity filtering, along the lines of what already exists for the Location module when used with Views Global Filter.

Switching to the Location module may in fact be the quickest implementation path for you, Nico, unless you're already entrenched in Geofield as the location coordinates storage module.
Architecturally I prefer Geofield over Location, as Geofield uses the D7 field & entity API's, but to the end user that makes little difference.

Rik

pixelsweatshop’s picture

Ah gotcha.

What about looking this the other way around? What if Views Global Filter supported regular filters? There are many instances, not just with Geofield, where one might want to preset their regular exposed info.

Switching to the Location module may in fact be the quickest implementation path for you, Nico, unless you're already entrenched in Geofield as the location coordinates storage module.

We have been on the fence about this. Much like you, we prefer geofield's approach/architecture. That being said we are not locked in at this point and still weighing options.

We are now experimenting with leveraging ip_geoloc for some of the wonderful extra map setting (marker differentiators, Map centering options, Marker tooltips, Marker tags, etc.) but may look at this patch for getting geofield to work with smartIP #1901750: Integrate Smart IP with Geofield's Views proximity handlers

While this approach may be redundant as ip_geoloc is already doing some of this work, it may work for what we need.

RdeBoer’s picture

What if Views Global Filter supported regular filters?

That would be both wonderful and very ambitious... It's a thought that will keep lingering in the back of my mind...

So from that first patch in #1901750: Integrate Smart IP with Geofield's Views proximity handlers, if you change:

      // Use Smart IP location, if module loaded.
      if (module_exists('smart_ip')) {
        return array(
         'latitude' => $_SESSION['smart_ip']['location']['latitude'],
         'longitude' => $_SESSION['smart_ip']['location']['longitude']
       );
        ....

to

      // Use IP Geolocation, if module loaded.
      if (module_exists('ip_geoloc')) {
        $location = ip_geoloc_get_visitor_location(); 
        return isset($location['latitude'] ? 
          ? array('latitude' => $location['latitude'], 'longitude' => $location['longitude'])
          : array('latitude' => 0, 'longitude' => 0);
      ....

then you get the visitor's HTML5 location (satellite and Wifi based), with the IP address-based lookup by Smart IP as a backup.

You'll probably want to to do a similar thing for the second part of the patch:

    if (module_exists('smart_ip') && !empty($_SESSION['smart_ip']['location']['city'])) {
      $smartip_city = $_SESSION['smart_ip']['location']['city'];
      $smartip_country = $_SESSION['smart_ip']['location']['country'];
      ...

becomes:

    if (module_exists('ip_geoloc')) {
       $location = ip_geoloc_get_visitor_location(); 
       if (isset($location['locality'])) {
         $smartip_city = $location['locality'];
         $smartip_country = $location['country'];
         ...
RdeBoer’s picture

Actually forget all of the above in #9.
I just created this #2011340: Geofield plugin to extend proximity filtering based on postal address with option to use HTML5 location.
Give that a go. It works nicely for me.
All it needs is a bit of CSS to style the distance and address input fields.

pixelsweatshop’s picture

Wow. I woke up this morning and it was just like christmas. I'll give that patch a test. You're a rockstar, Rik.

RdeBoer’s picture

Haha... maybe there's a career for me as Santa...

RdeBoer’s picture

Title: Using views global filter with Geofield 7.x-2.x proximity » Using Views Global Filter with Geofield 7.x-2.x proximity
Component: Documentation » Miscellaneous
Assigned: Unassigned » RdeBoer
Category: support » feature
Status: Active » Fixed

The latest version of Views Global Filter 7.x-1.x-dev has a Proximity global filter that works with the Location module as well as Geofield 7.x-2.x (provided this patch, #2014345: Geofield plugin for Contextual Proximity Filter is applied).

The Proximity filter comes with its own widget, which prompts the user for a distance from a reference point. The reference point can be entered as a partial address (eg "Broadway, New York") or left blank, in which case the visitor's current HTML5-retrieved location will be used.

Status: Fixed » Closed (fixed)

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

RaulMuroc’s picture

I think would be nice to put efforts on:

Geofield Proximity Filter

To make it a real project :)

pixelsweatshop’s picture

@RaulMuroc, I am not sure what that sandbox project has to do with this issue. This issue is about supporting geofield's 2.x already built in proximity features. Allowing user defined selections persist through multiple views. I am not positive but that sandbox project was built before geofield had its own proximity search handler. Furthermore that sandbox project is for solr support which is not always a possibility with every project and many times it is overkill for small to moderate projects.

sbydrupal’s picture

Tried both field and views solutions and can't seem to put it together to create a views global filter block to work with geofield proximity.
Is it currently working for everybody else ?

Set up is:
------------

- a content type has addressfield and geofield. Geofield gets its input from geocoded addressfield.
- trying to filter two views with the same views global filter block.

Problem: Can't seem to find geofield proximity filter field selection in global views block.
There is only geofield field. When this field is selected, non of the widget selections comes up with
a solution...

Tried creating a view instead of using field to feed the global views block... Still no luck.

Thanks for any input.

RdeBoer’s picture

@sbydrupal
Sorry it's not working for you.

Can you please confirm you're using Geofield 2.x with the patch from #13 in this thread?
And Global Filter 7.x-1.x ?

Rik

sbydrupal’s picture

Thanks Rik for your quick reply as I got stuck on this subject, and much appreciate your help.

Yes, Global Filter version is 7.x-1.11
and Geofield version is 7.x-2.1

They are both last versions posted.

Just applied patch #34 to geofield handler argument proximity #24 at the link below:
https://drupal.org/node/2014345#comment-7638461

There is no change in the results so far. In the global view filter block, I see "geo field" and select it. Then, the only widget related to geo field is "Inherit geocoder widget from field Geofield", which doesn't provide any results...

What am I doing wrong here ?

Thanks!

RdeBoer’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

Hmmm... Not sure. I'm not even near a computer right now.
You'll have to wait for my help till the weekend
Rik

sbydrupal’s picture

Thanks Rik. The set up is as mentioned above:

In a content type,

- created addressfield
- created geofield as having input from addressfield

In Global Views filter block, I see only geofield and widget is "inherit geocode widget..."

Thanks!