You are here

function _openlayers_layers_include_map_api in Openlayers 6

Include Mapi API

Function to include any third-party APIs for layers

Parameters

$type: String of type to include

1 call to _openlayers_layers_include_map_api()
openlayers_layers_process_layers in modules/openlayers_layers/includes/openlayers_layers.layers.inc
Process Layers

File

modules/openlayers_layers/includes/openlayers_layers.layers.inc, line 334
This file holds the main Drupal hook functions and private functions for the openlayers module.

Code

function _openlayers_layers_include_map_api($type = '') {
  static $included = array();

  // Check if already included
  if (!$included[$type] && $type) {
    switch ($type) {
      case 'google':

        // Include Google Map API JS (maybe getting key from GMap)
        drupal_set_html_head('<script src="' . check_url("http://maps.google.com/maps?file=api&v=2&sensor=false&key=" . variable_get('openlayers_layers_google_api', variable_get('googlemap_api_key', ''))) . '" type="text/javascript"></script>');
        break;
      case 'yahoo':
        drupal_set_html_head('<script src="' . check_url("http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=" . variable_get('openlayers_layers_yahoo_api', '')) . '" type="text/javascript"></script>');
        break;
      case 'virtual_earth':
        drupal_set_html_head('<script src="' . check_url("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1") . '" type="text/javascript"></script>');
        break;
    }
    $included[$type] = TRUE;
  }
}