function colorized_gmap_build_api_url in Colorized google maps block 7
Builds the javascript maps api url based on authentication method.
2 calls to colorized_gmap_build_api_url()
- colorized_gmap_block_configure in ./
colorized_gmap.module - Implements hook_block_configure().
- colorized_gmap_block_view in ./
colorized_gmap.module - Implements hook_block_view().
File
- ./
colorized_gmap.module, line 504 - Colorized gmap module.
Code
function colorized_gmap_build_api_url() {
// Google api url.
$api_url = '//maps.googleapis.com/maps/api/js';
// Array to hold query parameters for the google maps url.
// Including version number as it's required for Premium plans.
// https://developers.google.com/maps/documentation/javascript/versions
$query = array(
'v' => '3',
);
switch (variable_get('colorized_gmap_auth_method')) {
case 1:
$key = variable_get('colorized_gmap_api_key', '');
if (!empty($key)) {
$query['key'] = $key;
}
break;
case 2:
$client_id = variable_get('colorized_gmap_client_id', '');
$private_key = variable_get('colorized_gmap_private_key', '');
if (!empty($client_id)) {
$query['client'] = $client_id;
if (!empty($private_key)) {
$query['signature'] = $private_key;
}
}
break;
}
// Add query params to API url.
if (!empty($query)) {
$api_url .= '?' . drupal_http_build_query($query);
}
return $api_url;
}