function _ip_geoloc_custom_formatted_address in IP Geolocation Views & Maps 7
2 calls to _ip_geoloc_custom_formatted_address()
- ip_geoloc_tokens in ./
ip_geoloc.tokens.inc - Implements hook_tokens().
- _ip_geoloc_set_my_location_add_address in ./
ip_geoloc_blocks.inc
File
- ./
ip_geoloc.module, line 1025 - IPGV&M is a mapping engine for Views that contain locations of entities and/or visitors. Google Maps, Leaflet and OpenLayers2 maps are all supported. and available through this module. Using a number of optional sources IPGV&M also retrieves…
Code
function _ip_geoloc_custom_formatted_address($location, $need_street = FALSE, $need_locality = FALSE, $need_country = FALSE) {
if (!$need_street && !$need_locality && !$need_country) {
return $location['formatted_address'];
}
$address = '';
if ($need_street) {
if (!empty($location['street_number'])) {
$address = $location['street_number'];
}
if (!empty($location['route'])) {
$address .= empty($address) ? $location['route'] : ' ' . $location['route'];
}
}
if ($need_locality) {
if (!empty($address) && !empty($location['locality']) && !empty($location['administrative_area_level_1'])) {
$address .= ', ';
}
if (!empty($location['locality'])) {
$address .= $location['locality'];
}
if (!empty($location['administrative_area_level_1'])) {
$address .= (empty($location['locality']) ? '' : ', ') . $location['administrative_area_level_1'];
}
if (!empty($location['postal_code'])) {
$address .= ' ' . $location['postal_code'];
}
}
if ($need_country) {
if (!empty($address)) {
$address .= ', ';
}
$address .= $location['country'];
}
return $address;
}