From looking at - http://drupal.org/update/modules/6/7#drupal_add_library

Looks like we should be using more code like:

function openlayers_include() {
  // Use a static variable to prevent running URL check code repeatedly.
  static $once;
  if (!isset($once)) {
    $once = TRUE;

  drupal_add_library('openlayers', 'main-config');
  }
}


/**
 * Include necessary CSS and JS for rendering maps
 *
 * @ingroup openlayers_api
 */
function openlayers_library() {
    $path = check_plain(variable_get('openlayers_source', OPENLAYERS_DEFAULT_LIBRARY));
    // Check for full URL and include it manually if external.
    if (valid_url($path, TRUE)) {
      $openlayers_source_array => ('type' => 'external');
    }
    else {
       $openlayers_source_array = array();
    }

  $libraries['main-config'] = array(
    'title' => 'Main Configuration Files',
    'js' => array(
      $path => $openlayers_source_array,
    ),
    'js' => array(
      'js/openlayers.js' => array(),
    ),
    'css' => array(
      'js/openlayers.cs' => array(),
    ),
  );
  return $libraries;
}

Comments

zzolo’s picture

Title: switch to using openlayers_library » Utilize Libraries API
Version: 7.x-2.x-dev » 7.x-3.x-dev

Hey @mgifford. I am not sure how appropriate this as we allow for the library location to be a setting.

In 3.x, I think we will address this with the Libraries API, and hopefully some sort of bundling or downloaded version of the Library.

mgifford’s picture

No problem.. Although the setting for OpenLayers.js is just one of many that gets loaded. Each layer or behavior has one or two files it needs to load when it is enabled.

Pol’s picture

Status: Active » Needs work
m.stenta’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

Openlayers uses Libraries API now, so I think this is all done! Closing...