Hi All,

Having an issue with proximity filter whereby a postcode on its own wont return a result eg.3199, but typing in 3199, Australia works. Is it possible to have it only geocode locations within a specific country?

Appreciate any insight on the matter.
Ben

Comments

simon georges’s picture

By using the Addressfield module to handle the address part, I think you may force the country.

benjmarr’s picture

unfortunately this doesn't work. We are using the proximity exposed filter with the source of origin point being"geocoded location" using the google geocoder service.

benjmarr’s picture

Priority: Normal » Major

Hi All,

This is now major... when searching a postcode say 3000 no results are shown. The user has to search 3000, Australia. I have gone through the code and tried a few things but no success is there anywhere that i can add ,Australia so it processes the users entry with ,Australia appended?

Thanks,
Ben

benjmarr’s picture

still messing around trying to get geofield to process a geocoded location by appending ,t(Australia) but cant get it to work.

benjmarr’s picture

any gurus here to weigh in on wether this is possible or not?

p_stampy’s picture

We've just come across the same problem too, will be interested to see if there is an outcome.

p_stampy’s picture

Some additional information, typing in "2012, Australia" actually brings up results around Adelaide/SA instead of Sydney...

benjmarr’s picture

still trying to find a solution for this but this is certainly not our forte!!

p_stampy’s picture

Hi,

I'm not sure if this is in the right place, but this has worked for us when using "openlayers_proximity" to do the proximity search on aussie post codes.

In sites\all\modules\openlayers_proximity open up openlayers_proximity.module

For me it starts on line 387...

 * Query Google geocoding web service.
 *
 * @param $address Address or location name.
 * @return Geocoder response.
 */
function openlayers_proximity_geocode($address) {

  $locations = $args = array();
  
  // INSERT AU - replace "$address" below with "$address . ', AU'"
  // $address is the string that tells the map what to look for (from what I can assume from reading the code anyway
  // the ". ', AU'" is for PHP to ADD to extend/add to a string. what i can assume is that $args['address'] is just a holder that replaces spaces with + signs, and the string to replace them in is $address.
  // this then stores the replaced string into $args['address'] and is then used elsewhere in this function
  // this might not be the best way to intercept the value, and would probably be good to test it on a few other locations and see if it errors or whatever, but i think it should be OK
  // but it does keep the modification invisible to the user
  $args['address'] = str_replace(' ', '+', $address . ', AU');
  $language = language_default();
  $args['language'] = $language->language;
  $args['oe'] = 'utf-8';
  $args['sensor'] = 'false';
  $query = http_build_query($args, '', '&');

Anyway, hope that might help a little bit...

bneil’s picture

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

Duplicate in favor of #2014621: Geofield proximity + postal code to find a solution as its obviously a non-specific country issue. Comment 14 in that issue also provides a work around that can be used via a new hook.