I could never get the bounding box argument to work in 8.x-1.x branch - it never appeared as an option to even add it. This fixes that, simplifies the codebase a little, and works with both geofield and geolocation fields. It also provides the option to round the coordinates down to 2 decimal places which may help a little with cacheing SQL queries. It doesn't yet support lat-long fields or wrapping around the -180/180 degree lines.
You use it like you would any contextual filter, ie provide a default value from a Query parameter, and set the name of the query parameter to bbox.
No automated tests yet, but manually tested with both geofield and geolocation fields using leaflet.
Comments
Comment #2
alarcombe commentedComment #3
polComment #4
polThanks I will review this asap.
Comment #5
vdsh commentedI just realized that I kinda duplicated your work with #3086063: Views bbox contextual filter not working, sorry about that (and that could have saved me quite some time!).
My patch doesn't have rounding capabilities but it has wrapping around the -180° line.
We should probably somehow do a merge of both & commit that to the latest dev.
Comment #6
jeffschulerThanks @alarcombe!
Rerolled for latest 8.x-1.x-dev, plus a few minor changes.
I believe this is working at least well enough to commit to dev (since what's in there doesn't work at all), which I'll do now.
@vdsh: I haven't checked out your version in #3086063: Views bbox contextual filter not working (yet). If you want to open a new issue with patch for adding wrapping around -180º/180º (and/or any other improvements from your version) that would be great. Thanks!
Comment #8
jeffschulerComment #10
vdsh commentedFor anyone interested, wrapping patch is here: #3107187: Bounding Box argument: Support 360° wrapping and I also added latlon support in here #3107173: Bounding Box argument: Support latlon field