]> git.openstreetmap.org Git - rails.git/blob - public/lib/OpenLayers.js
Tidy things up a bit.
[rails.git] / public / lib / OpenLayers.js
1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3  * text of the license. */
4 ////
5 /// This blob sucks in all the files in uncompressed form for ease of use
6 ///
7
8 OpenLayers = new Object();
9
10 OpenLayers._scriptName = ( 
11     typeof(_OPENLAYERS_SFL_) == "undefined" ? "lib/OpenLayers.js" 
12                                             : "OpenLayers.js" );
13
14 OpenLayers._getScriptLocation = function () {
15     var scriptLocation = "";
16     var SCRIPT_NAME = OpenLayers._scriptName;
17  
18     var scripts = document.getElementsByTagName('script');
19     for (var i = 0; i < scripts.length; i++) {
20         var src = scripts[i].getAttribute('src');
21         if (src) {
22             var index = src.lastIndexOf(SCRIPT_NAME); 
23             // is it found, at the end of the URL?
24             if ((index > -1) && (index + SCRIPT_NAME.length == src.length)) {  
25                 scriptLocation = src.slice(0, -SCRIPT_NAME.length);
26                 break;
27             }
28         }
29     }
30     return scriptLocation;
31 }
32
33 /*
34   `_OPENLAYERS_SFL_` is a flag indicating this file is being included
35   in a Single File Library build of the OpenLayers Library.
36
37   When we are *not* part of a SFL build we dynamically include the
38   OpenLayers library code.
39
40   When we *are* part of a SFL build we do not dynamically include the 
41   OpenLayers library code as it will be appended at the end of this file.
42 */
43 if (typeof(_OPENLAYERS_SFL_) == "undefined") {
44     /*
45       The original code appeared to use a try/catch block
46       to avoid polluting the global namespace,
47       we now use a anonymous function to achieve the same result.
48      */
49     (function() {
50     var jsfiles=new Array(
51         "Prototype.js", 
52         "Rico/Corner.js",
53         "Rico/Color.js",
54         "OpenLayers/Util.js",
55         "OpenLayers/Ajax.js",
56         "OpenLayers/Events.js",
57         "OpenLayers/Map.js",
58         "OpenLayers/Layer.js",
59         "OpenLayers/Icon.js",
60         "OpenLayers/Marker.js",
61         "OpenLayers/Popup.js",
62         "OpenLayers/Tile.js",
63         "OpenLayers/Feature.js",
64         "OpenLayers/Feature/WFS.js",
65         "OpenLayers/Tile/Image.js",
66         "OpenLayers/Tile/WFS.js",
67 //        "OpenLayers/Layer/Google.js",
68 //        "OpenLayers/Layer/VirtualEarth.js",
69 //        "OpenLayers/Layer/Yahoo.js",
70         "OpenLayers/Layer/Grid.js",
71         "OpenLayers/Layer/KaMap.js",
72         "OpenLayers/Layer/Markers.js",
73         "OpenLayers/Layer/Text.js",
74         "OpenLayers/Layer/WMS.js",
75         "OpenLayers/Layer/WFS.js",
76         "OpenLayers/Layer/WMS/Untiled.js",
77         "OpenLayers/Popup/Anchored.js",
78         "OpenLayers/Popup/AnchoredBubble.js",
79         "OpenLayers/Control.js",
80         "OpenLayers/Control/MouseDefaults.js",
81         "OpenLayers/Control/MouseToolbar.js",
82         "OpenLayers/Control/KeyboardDefaults.js",
83         "OpenLayers/Control/PanZoom.js",
84         "OpenLayers/Control/PanZoomBar.js",
85         "OpenLayers/Control/LayerSwitcher.js"
86     ); // etc.
87
88     var allScriptTags = "";
89     var host = OpenLayers._getScriptLocation() + "lib/";
90
91     // check to see if prototype.js was already loaded
92     //  if so, skip the first dynamic include 
93     //
94     var start=1;
95     try { x = Prototype; }
96     catch (e) { start=0; }
97
98     for (var i = start; i < jsfiles.length; i++) {
99         var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>"; 
100         allScriptTags += currentScriptTag;
101     }
102     document.write(allScriptTags);
103     })();
104 }