You are here

function legacy__gmap_base_js in GMap Module 7.2

Adds the basic js files needed for a GMap.

Is called by hook_element_info(). To add js-files for a specific Views display, please use _gmap_pre_render_map().

File

tests/inc/gmap_defaults.inc, line 70
Contains gmap_defaults.inc

Namespace

tests\inc

Code

function legacy__gmap_base_js() {
  $ret = array();
  $path = drupal_get_path('module', 'gmap');

  // Convert some language codes.
  // For Google Maps API v3, the drupal language code
  // is not always the same as the google language code.
  // @see https://developers.google.com/maps/documentation/javascript/basics#Localization
  global $language;
  switch ($language->language) {

    // 'Chinese, Simplified'.
    case 'zh-hans':
      $langcode = 'zh-CN';
      break;

    // 'Chinese, Traditional'.
    case 'zh-hant':
      $langcode = 'zh-TW';
      break;

    // Hebrew.
    case 'he':
      $langcode = 'iw';
      break;

    // 'Norwegian Bokm�l', 'Bokm�l'.
    case 'nb':

    // 'Norwegian Nynorsk', 'Nynorsk'.
    case 'nn':

      // 'Norwegian'.
      $langcode = 'no';
      break;
    default:
      $langcode = $language->language;
      break;
  }
  $m = array();
  $query = array(
    'v' => variable_get('gmap_api_version', GMAP_API_VERSION),
    'language' => $langcode,
    'sensor' => 'false',
    'libraries' => implode(array_merge(variable_get('gmap_api_libraries', array()), legacy_gmap_module_invoke('libraries', $m)), ','),
  );
  if ($key = legacy_gmap_get_key()) {
    $query['key'] = $key;
  }
  $ret[$path . '/js/gmap.js'] = array(
    'weight' => 1,
  );
  $ret[$path . '/js/icon.js'] = array(
    'weight' => 2,
  );
  $ret[$path . '/js/marker.js'] = array(
    'weight' => 2,
  );
  $ret[$path . '/js/highlight.js'] = array(
    'weight' => 2,
  );
  $ret[$path . '/js/poly.js'] = array(
    'weight' => 2,
  );
  $ret[url(legacy_gmap_views_protocol() . '://maps.googleapis.com/maps/' . 'api/js', array(
    'query' => $query,
  ))] = array(
    'type' => 'external',
    'weight' => 1,
  );
  $ret[base_path() . variable_get('file_public_path', conf_path() . '/files') . '/js/gmap_markers.js'] = array(
    'type' => 'external',
    'weight' => 4,
  );
  return $ret;
}