It would be nice to be able to add region biasing when users are searching for addresses in views. This is a similar issue to: #1909706: Support Google's "bounds" parameter, where region biasing has been added when a field is geocoded.

The same functionality would be nice when a field is being search upon.

Comments

Sam152’s picture

Since geofield calls geocoder (when they are both installed), rolling in patch #1909706 makes it easier to add thins functionality. Once that patch is rolled in "getSourceValue" in "geofield/views/proximity_plugins/geofieldProximityGeocoder.inc" can be updated to include the region like so

$geocoded_data_raw = geocoder($geocoder_engine, $location, array('biasing' => array('region' => SELECTED_REGION)));

But for this to work, a field has to be added to the handler which collects this information.

Is there any more experienced with this module willing to work to get these two bits of functionality working togehter.

Sam152’s picture

Issue summary: View changes
fonant’s picture

There is a pretty quick workaround that works for all Google geocoding, including proximity filters, using hook_url_outbound_alter() in a custom module: #1909706-22: Support Google's "bounds" parameter

/**
 * Implements hook_url_outbound_alter().
 */
function MODULE_url_outbound_alter(&$path, &$options, $original_path) {
  // Modify reguests to Google geocoder API so we focus on results in the UK.
  if ($path == 'http://maps.googleapis.com/maps/api/geocode/json') {
    $options['query']['region'] = 'UK';
  }
}

You need to clear the cache_geocoder table before the locations will be re-geocoded with the region biasing included.