Views Argument Handler for Proximity
| Project: | Location |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
I have created a views argument handler for proximity.
You can use the argument in two ways, by postal code and distance or by coordinate and distance.
Example: view path is content-listing
content-listing/[postal_code]+[distance]
content-listing/75214+10
The above argument will restrict content within 10 miles of zipcode 75214.
Coordinates can also be passed.
content-listing/[lattitude],[longitude]+[distance]
content-listing/32.783,-96.8+25
Options for the argument handler are:
* Coordinate Description
Radio for either postal code that gets translated to rough coordinates or exact coordinates
* Unit Type
Miles or Kilometers. Unit type is set as an option, not encoded in the argument.
* Method
The views query is modified similar to how the proximity filter already works. And you can choose between a radial or rectangular search.
location.views.inc was modified to register the new handler in
location_views_handlers() and location_views_data()
A new file handlers/location_handler_argument_location_distance.inc was created.
I need to do a little cleanup and will post the code later this weekend. Bdragon, can we schedule a time for me to run some questions by you on IRC or email?
| Attachment | Size |
|---|---|
| proximity-argument.png | 56.19 KB |

#1
Does it support a default on the second argument, so that it would work as just "content-listing/75214"?
#2
Not currently. I didn't even think of that until I read your post. It's a good idea. I'll make that change before I post the code here.
#3
Great, I look forward to testing it :-)
#4
I think that postal code only is not appropriate to use with a proximity argument handler. It should have its own argument handler.
Doesn't like me adding the new file as a .inc, so I just appended .patch. It's not really a patch file.
#5
i can confirm that the patch and inc file works. very nice work, thanks you for your effort. karma+1
i noticed that the sorting by proximity/distance as well as the display of proximity do not work. the field is empty.
it's still very usable to show all marker inside a defined distance.
#6
Awesome. Excellent. Check out http://drupal.org/node/357295 which is the main queue for this problem....
What's the process on getting this committed? I'll install a fresh installation of drupal and load it on and write a little report on how it works/how it can be improved.
Thanks again for spending the time to do this!
#7
Can't get postal code to set
I've patched the -dev version and added the handler which exposes the functionality just fine, but I can't get the argument to work properly. Neither of the radios are checked for type of center point and the query seems to indicate that lat/long is selected even when I specifically select postal code and save?
AND (location.latitude > 0 AND location.latitude < 0 AND location.longitude > 0 AND location.longitude < 0)(it may just be for validation and not affecting the query - not sure). I'm not a php coder, but I'm pretty handy with drupal/cck/views/panels and happy to help with testing/config as I really need to get zipcode arguments to work for my production site.
Drupal 6.14
MySQL 5.1.36
Views 6.x-2.6
#8
dchampine, email me dustinc@getlevelten.com so we can get together and resolve what you are seeing.
#9
Can someone confirm if the patches above can be used for use with cck location as well?
Thanks.
#10
subscribe
#11
I am not sure I understand how to implement once you have applied the patch and added the new .inc file. I believe I have done those parts correctly and was expecting to see a change available in my views configuration area. Where should I go to implement this feature?
Thanks
#12
Sorry for the mixup, I found my error and it is simply a matter of adding the Proximity/Location drop down to the arugments view area.