function ip_geoloc_build_google_api_url in IP Geolocation Views & Maps 7
Same name and namespace in other branches
- 8 ip_geoloc.module \ip_geoloc_build_google_api_url()
Builds the javascript maps api url based on authentication method.
Patch from https://www.drupal.org/node/2776209
1 call to ip_geoloc_build_google_api_url()
- ip_geoloc_api.inc in ./
ip_geoloc_api.inc - API functions of IP geolocation module
File
- ./
ip_geoloc.module, line 987 - 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_build_google_api_url() {
// Append query parameters for the Google Maps url.
// See https://developers.google.com/maps/documentation/javascript/versions
$query = array();
switch (variable_get('ip_geoloc_auth_method', 0)) {
case 1:
$key = trim(variable_get('ip_geoloc_apikey', ''));
if (!empty($key)) {
$query['key'] = $key;
}
break;
case 2:
$client_id = trim(variable_get('ip_geoloc_client_id', ''));
if (!empty($client_id)) {
$query['client'] = $client_id;
$signature = trim(variable_get('ip_geoloc_signature', ''));
if (!empty($signature)) {
$query['signature'] = $signature;
}
}
break;
default:
return '';
}
// Add query params to API URL and return.
if (!empty($query)) {
$query['v'] = 'weekly';
$query['libraries'] = 'places';
return 'https://maps.googleapis.com/maps/api/js?' . drupal_http_build_query($query);
}
return '';
}