You are here

function styled_google_map_build_api_url in Styled Google Map 7.2

Same name and namespace in other branches
  1. 8.2 styled_google_map.module \styled_google_map_build_api_url()
  2. 8 styled_google_map.module \styled_google_map_build_api_url()

Builds the javascript maps api url based on authentication method.

2 calls to styled_google_map_build_api_url()
styled_google_views_preprocess_styled_google_view in styled_google_views/styled_google_views.module
Implements hook_preprocess_HOOK().
theme_styled_google_map in ./styled_google_map.module
Returns HTML for the styled google map.

File

./styled_google_map.module, line 693
Contains all hooks and functions for the Styled Google Map module.

Code

function styled_google_map_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('styled_google_map_google_auth_method')) {
    case STYLED_GOOGLE_MAP_GOOGLE_AUTH_KEY:
      $key = variable_get('styled_google_map_google_apikey', FALSE);
      if (!empty($key)) {
        $query['key'] = $key;
      }
      break;
    case STYLED_GOOGLE_MAP_GOOGLE_AUTH_WORK:
      $client_id = variable_get('styled_google_map_google_client_id', FALSE);
      if (!empty($client_id)) {
        $query['client'] = $client_id;
      }
      break;
  }

  // Add query params to API url.
  if (!empty($query)) {
    $api_url .= '?' . drupal_http_build_query($query);
  }
  return $api_url;
}