public function IpGeoLocGlobal::formatAddress in IP Geolocation Views & Maps 8
Poor man's address formatter.
It doesn't take local format conventions into account. Luckily this is only called as a fallback when lat/long could not be established or the Google reverse-geocode function returned an error.
Parameters
array $location: Array of location components.
File
- src/
Services/ IpGeoLocGlobal.php, line 251
Class
- IpGeoLocGlobal
- Class IpGeoLocGlobal.
Namespace
Drupal\ip_geoloc\ServicesCode
public function formatAddress(array &$location) {
$location['formatted_address'] = isset($location['city']) ? $location['city'] : '';
if (!empty($location['region'])) {
$location['formatted_address'] .= ' ' . $location['region'];
}
if (!empty($location['postal_code']) && $location['postal_code'] != '-') {
$location['formatted_address'] .= ' ' . $location['postal_code'] . ',';
}
if (!empty($location['country'])) {
$location['formatted_address'] .= ' ' . $location['country'];
}
$location['formatted_address'] = trim($location['formatted_address']);
}