Zip Code searches utilizing the Google API

I have some experience with using the Google API and Fabrik. For example, I used it to determine who receives an email inquiry based upon the distance between the submitter of the enquiry and the potential recipients. That works fine.

Now I need to filter a list using a customer's postcode submittal. The Radius Plugin won't really work for me. It's a little cumbersome and would require customization anyway to allow submission of the zip code.

I'm thinking a form with a redirect to the list with the search option on, but I cannot figure out how and where to code this. Obviously, a simple search for the same zip code won't work. I want records that have zips within a certain distance, like 20 miles. I know how to formulate the Google API request and process the result. I just can't figure out how to use the Fabrik form redirect to do it.

Maybe there's a better way?
 
You'd probably have to do it by building a your list filter query dynamically in JavaScript. Have a form with a field element for ZIP input, and a JS event on that.

In the JS, get your list of geolocated ZIP's from Google, then construct a URL to the list with that list of ZIP's on the query string - see the wiki on how to build query string filters for lists, but the basic approach would be ...

Code:
index.php?option=com_fabrik&view=list&listid=123&yourtable___zip[value][]=12345&yourtable___zip[value][]=54321&yourtable___zip[join]=OR

In other words, as many &yourtable___zip[value][]=xxxxx as you need, and a [join]=OR.

Then do a location.assign(url).

-- hugh
 
Appreciate the reply, but my JS skills are extremely limited, and I avoid it as much as possible.

I did come up with a PHP-based solution, however, similar to what I was thinking.

I use a form to collect the zip and distance, and form PHP to access the Google API and find which records meet the criteria. I collect the ids of those records in a comma separated list and store it in a Joomla session variable. The form then redirects to a list.

The list has an EVAL pre-filter that accesses the Joomla session variable and returns it. The pre-filter then looks for records that are IN that comma separated list.

Seems to work very well and quite quickly, even on large numbers of records.
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top