You are here

function openlayers_initialize in Openlayers 6

Intialize OpenLayers

Make sure that we have everything we need for OpenLayers

Parameters

$params: Associative array of pamaters (none at the moment)

Return value

Boolean if intialization was succesful

Related topics

2 calls to openlayers_initialize()
openlayers_admin_settings in includes/openlayers.admin.inc
Menu callback; displays the openlayers module settings page.
openlayers_render_map in ./openlayers.module
Render Map

File

./openlayers.module, line 124
Main OpenLayers API File

Code

function openlayers_initialize() {
  $success = TRUE;

  // Include the OpenLayers JS
  // We need to check if it a local path or URL, but really only need to do it once.
  static $included = FALSE;
  if ($included == FALSE) {
    $path = check_plain(variable_get('openlayers_source', 'http://openlayers.org/api/OpenLayers.js'));

    // Check for full URL
    if (valid_url($path, TRUE)) {

      // If URL, we have to manually include it in Drupal
      drupal_set_html_head('<script src="' . check_url($path) . '" type="text/javascript"></script>');
    }
    else {

      // Ensure that the JS file is not aggregated with the rest
      drupal_add_js($path, 'module', 'header', FALSE, TRUE, FALSE);
    }

    // Add CSS
    drupal_add_css(drupal_get_path('module', 'openlayers') . '/openlayers.css', 'module');

    // Add base JS file
    drupal_add_js(drupal_get_path('module', 'openlayers') . '/js/openlayers.js', 'module');
    $included = TRUE;
  }
  return $success;
}