You are here

function _gmap_doheader in GMap Module 5

Same name and namespace in other branches
  1. 6.2 gmap.module \_gmap_doheader()
  2. 6 gmap.module \_gmap_doheader()
  3. 7.2 gmap.module \_gmap_doheader()
  4. 7 gmap.module \_gmap_doheader()

Set up the HTML header for GMap. If you are going to include a custom JS file that extends GMap, you probabaly want to call this first to ensure that the core js files have been added.

1 call to _gmap_doheader()
theme_gmap in ./gmap.module
Gmap element theme hook

File

./gmap.module, line 257
GMap -- Routines to use the Google Maps API in Drupal.

Code

function _gmap_doheader() {
  static $gmap_initialized = FALSE;
  if ($gmap_initialized) {
    return;
  }
  $gmap_path = drupal_get_path('module', 'gmap');
  drupal_add_css($gmap_path . '/gmap.css');
  drupal_add_js($gmap_path . '/js/gmap.js');
  $mm = variable_get('gmap_mm_type', 'gmap');
  $mms = variable_get('gmap_markermanager', array());
  if (empty($mms[$mm])) {
    $mms[$mm] = array();
  }

  // If you really really want to override the marker manager, implement
  // this, take $mm by ref, and have fun. --Bdragon
  if (function_exists('_gmap_markermanager_override')) {
    _gmap_markermanager_override($mm, $mms);
  }
  if ($mm == 'clusterer' || $mm == 'clustermarker') {

    // Needed for access to clusterer marker.
    drupal_add_js($gmap_path . '/js/icon.js');
  }
  if (isset($mms[$mm]['filename'])) {
    drupal_add_js($gmap_path . '/thirdparty/' . $mms[$mm]['filename']);
  }
  drupal_add_js($gmap_path . '/js/marker.js');
  drupal_add_js($gmap_path . '/js/' . $mm . '_marker.js');
  drupal_add_js(array(
    'gmap_markermanager' => $mms[$mm],
  ), 'setting');

  // @@@
  drupal_add_js($gmap_path . '/js/poly.js');
  global $locale;
  $query = array(
    'file' => 'api',
    'v' => variable_get('gmap_api_version', GMAP_API_VERSION),
    'key' => gmap_get_key(),
    'hl' => $locale,
  );
  drupal_set_html_head('<script src="' . check_url(url('http://maps.google.com/maps', drupal_query_string_encode($query))) . '" type="text/javascript"></script>');
  $gmap_initialized = TRUE;
}