You are here

function gm3_add in Google Maps API V3 7

Callback to add a Google map to a specific element ID on the page.

1 call to gm3_add()
gm3_get_map in ./gm3.theme.inc
Function to return a renderable array for a map.

File

./gm3.theme.inc, line 146

Code

function gm3_add(&$map = array()) {
  $map['settings'] = array_merge(gm3_settings(), isset($map['settings']) ? $map['settings'] : array());
  drupal_alter('gm3_map', $map);
  if (isset($map['libraries']) && is_array($map['libraries'])) {
    foreach ($map['libraries'] as $library => $settings) {
      $module = 'gm3';
      if (is_array($settings)) {
        $module = isset($settings['module']) ? $settings['module'] : $module;
      }
      else {
        $map['libraries'][$settings] = $settings;
        unset($map['libraries'][$library]);
        $library = $settings;
      }
      $library = $module == 'gm3' ? "gm3.{$library}" : $library;
      drupal_add_library($module, $library);
    }
  }
  drupal_add_library('gm3', 'gm3');
  drupal_add_js(array(
    'gm3' => array(
      'maps' => array(
        $map['id'] => $map,
      ),
    ),
  ), 'setting');
}