OpenLayersExtLoader
A class for loading all necessary OLE files, which includes OpenLayersExt extended classes along with packaged external libraries such as OpenLayers, Prototype, Scriptaculous, and Proj4js, among others.
How to include
First, include the openlayers-ext-loader.js in the html document where OLE will be running. This single file is all you need to dynamically load all of OLE's JavaScript dependencies.
<script src="/<ole-base-path>/openlayers-ext/openlayers-ext-loader.js" type="text/javascript"></script>
How to use
Once the openlayers-ext-loader.js file has been included, the OpenLayersExtLoader.load method may be invoked with it's options.
// load ole files with google and yahoo map libraries OpenLayersExtLoader.load({ "debug": true, "map-libs": { "google": { "version": "2", "key": "<google_api_key>" }, "yahoo": { "version": "3.0", "key": "<yahoo_api_key>" } } });
Class Functions
load |
function( parameters ){} |
-
Loads all OLE JavaScript file dependencies. Map libraries (google, yahoo, microsoft...) are loaded on demand according to the "map-libs" parameter.
The load function receives an object of optional load parameters.
ParametersName Type Default Value
Description
debug boolean "" Turn on debugging options and firebug traces. map-libs object null An optional hash of map libraries to load config object null An optional hash of configuration options
The map-libs object{ "google": { "version": "2", "key": "<google_api_key>" }, "yahoo": { "version": "3.0", "key": "<yahoo_api_key>" }, "microsoft": { "version": "6.1", "key": "<microsoft_api_key>" } }
The config object{ "whatishere": { "enabled": true, "urls": { //categories: "/api/1.0/es/what-is-here/categories.json", //search: "/api/1.0/es/what-is-here/search/mbr/xmin/:xmin/ymin/:ymin/xmax/:xmax/ymax/:ymax/categories/:categories.:format", //geometry: "/api/1.0/es/what-is-here/geometry/code/:code.:format", //query: "/api/1.0/es/what-is-here/query/code/:code.:format" } } }
Don't forget your keys!
Every map-lib you decide to load will require a valid API key for each of your domains. For more information on how to obtain API keys for the map-libs you'd like to use, you will need to visit their respective websites.
Full Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>OLE - Basic Example</title> <script src="/<ole-base-path>/openlayers-ext/openlayers-ext-loader.js" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ OpenLayersExtLoader.load( { "debug": true, "map-libs": { "google": { "version": "2", "key": "<google_api_key>" }, "yahoo": { "version": "3.0", "key": "<yahoo_api_key>" } } } ); //]]> </script> <script type="text/javascript"> //<![CDATA[ Event.observe( window, "load", function() { window.b5map = new OpenLayersExt.Map( "mymap"); }); //]]> </script> </head> <body> <div id="mymap"></div> </body> </html>