Hello,

I need to calculate proximity from Argument passed to view and it looks like currently it impossible. Here is patch attached for file 'location/handlers/location_handler_field_location_distance.inc'. Basically, it adds new option to field 'Location: Distance / Proximity' -- 'Use Distance / Proximity argument'

Regards,
Pavel

Comments

pavel.karoukin’s picture

And identical patch for sorting ability by Distance/proximity from value passed as argument

yesct’s picture

There seem to be quite a few "handler" issues and patches recently in the issue queue. Someone, please search for them and see if any are duplicates and link them together, maybe use a location view handler "tag" on them.

yesct’s picture

tagging.

lance.gliser’s picture

I'm in need of this feature, and I could barely understand what the two patches listed here were after. I'm pretty sure they are on a different version of location as well. Still, it pointed me to enough of the right places for me to develop a patch against Location v6.x-3.1

Please review this patch. It's working well on my local and development servers.

lance.gliser’s picture

Version: 6.x-3.x-dev » 6.x-3.1-rc1
lance.gliser’s picture

Thought I'd give an update. The patch I attached here is still working for me. Just today, i created a relationship to a user, and was able to use the argument field and sort with no issue.

lance.gliser’s picture

I'm still hoping for a maintainer to review this for inclusion in the next release.

lance.gliser’s picture

Solution is still viable. Needs review.

deepeddy’s picture

+1 on this patch.

I just applied it and it does exactly what I need.

lance.gliser’s picture

I've just created a similar solution for D7 as well. I don't want to provide a patch for this one, as I might be stepping someone's toes. I found code 'close' to right for providing this functionality already in the location.views.inc file, and made slight modifications:

    case 'distance_arg':
      foreach ($view->argument as $argument) {
        if ($argument->field == 'distance' && !empty( $view->args[$argument->position]) ) {
          list($coords, $search_distance) = explode('_', $view->args[$argument->position]);
          list($lat, $lon) = explode(',', $coords);
          $coordinates['latitude'] = (float) $lat;
          $coordinates['longitude'] = (float) $lon;
          break;
        }
      }

Then just a small addition to the sort handler:

        'distance_arg' => t('Use Distance / Proximity argument'),

It seems like someone might already be working on this, or I've just run over code someone else has purposed for another reason. I'd appreciate some feedback on if that was patch worthy, or already covered.

D7 Location 7.x-3.x-dev

podarok’s picture

Version: 6.x-3.1-rc1 » 7.x-3.x-dev

all feature requests should be rolled against latest 7.x-3.x-dev and after commit can be backported to 6.x branch

Status: Needs review » Needs work
Issue tags: -location views, -location views handler

The last submitted patch, 732068-field-and-sort-by-location-argument.patch, failed testing.

mstrelan’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.52 KB

The attached patch allows for when the argument uses zip code lookup and provides ability to sort by this distance.

jacob.embree’s picture

Title: New param for Views field 'Location: Distance / Proximity' » Use Views argument as parameter for proximity/distance sort
Status: Needs review » Reviewed & tested by the community

It looks like this issue has changed a lot. It looks like the only thing left from the original report is to add the option to use a contextual filter as an argument to the proximity/distance sort handler. #14 is working for that.