Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
zzolo CreditAttribution: zzolo commentedHey @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.
Comment #2
mgiffordNo 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.
Comment #3
PolComment #4
m.stentaOpenlayers uses Libraries API now, so I think this is all done! Closing...