I am using the Google Store Locator module which also uses the Addressfield module for storing postal information. The address field module provides two lines for postal addresses:

Address 1
Address 2

where address 1 is generally the street address and address 2 is reserved for premise information (e.g. Unit #5, Suite 301 etc.)

My problem is that I am getting erroneous and incorrect geocoding results using the Google geocoder. Is there a simple way to ensure that the Google Geocoder only uses the Address 1 (street address location) for the lookup and ignores the Address 2 line from the address field module?

Comments

skalfyfan’s picture

UPDATE!

Just found the the method within geocoder.widget.inc.

/**
 * Geocoder Widget - Parse an address field
 */
function geocoder_widget_parse_addressfield($field_item) {
  $address = '';
  if (!empty($field_item['premise']))                 $address .= $field_item['premise'] . ',';
  if (!empty($field_item['thoroughfare']))            $address .= $field_item['thoroughfare'] . ',';
  if (!empty($field_item['locality']))                $address .= $field_item['locality'] . ',';
  if (!empty($field_item['administrative_area']))     $address .= $field_item['administrative_area'] . ',';
  if (!empty($field_item['sub_administrative_area'])) $address .= $field_item['sub_administrative_area'] . ',';
  if (!empty($field_item['country']))                 $address .= $field_item['country'] . ',';
  if (!empty($field_item['postal_code']))             $address .= $field_item['postal_code'] . ',';
    
  $address = rtrim($address, ', ');
  
  return $address;
}

Is there a simple way to hook into this and override it so that I can remove the premise part?

wranvaud’s picture

Status: Active » Closed (duplicate)
Related issues: +#1534474: Geocoding from Address Field - Sensitivity to address2

Duplicate of #1534474 (and they have a patch)