Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
on Openstreetmap nominatim API the Address resolving does not work properly if the postal codes is requestet AFTER the country, so im moved the postal-code Field in the "geocoder_widget_parse_addressfield"-Funktion (see geocoder.widget.inc) beforde the country like so:
function geocoder_widget_parse_addressfield($field_item) {
$address = array();
$address[] = !empty($field_item['organization']) ? $field_item['organization'] : NULL;
$address[] = !empty($field_item['premise']) ? $field_item['premise'] : NULL;
$address[] = !empty($field_item['sub_premise']) ? $field_item['sub_premise'] : NULL;
$address[] = !empty($field_item['thoroughfare']) ? $field_item['thoroughfare'] : NULL;
$address[] = !empty($field_item['locality']) ? $field_item['locality'] : NULL;
$address[] = !empty($field_item['administrative_area']) ? $field_item['administrative_area'] : NULL;
$address[] = !empty($field_item['sub_administrative_area']) ? $field_item['sub_administrative_area'] : NULL;
<strong>
$address[] = !empty($field_item['postal_code']) ? $field_item['postal_code'] : NULL;</strong>
if (!empty($field_item['country'])) {
if (module_exists('countries')) {
$country = country_load($field_item['country']);
$field_item['country'] = $country->name;
}
else {
// Convert country code to country name.
include_once DRUPAL_ROOT . '/includes/locale.inc';
$countries = country_get_list();
if (array_key_exists($field_item['country'], $countries)) {
$field_item['country'] = $countries[$field_item['country']];
}
}
$address[] = $field_item['country'];
}
return implode(',', array_filter($address));
}
Could anyone reply / confirm to this issue? Does anyone have a better solution?
Also https://www.drupal.org/node/1967520 could maybe fix this but still has "needs review"-status ...maybe anybody can add this to the latest 7.x-1.x-dev ???
Comments
Comment #2
drudev12 CreditAttribution: drudev12 commentedSee also:
WORKS:
http://nominatim.openstreetmap.org/?q=Hauptstra%C3%9Fe+15,Stuttgart,7056...
DOES NOT WORK (PLZ as last Param!):
http://nominatim.openstreetmap.org/?q=Hauptstra%C3%9Fe+15,Stuttgart,Deut...
Comment #3
Pol