Index: trunk/extensions/SlippyMap/OpenStreetMap.js |
— | — | @@ -1,214 +0,0 @@ |
2 | | -/** |
3 | | - * Namespace: Util.OSM |
4 | | - */ |
5 | | -OpenLayers.Util.OSM = {}; |
6 | | - |
7 | | -/** |
8 | | - * Constant: MISSING_TILE_URL |
9 | | - * {String} URL of image to display for missing tiles |
10 | | - */ |
11 | | -OpenLayers.Util.OSM.MISSING_TILE_URL = "http://openstreetmap.org/openlayers/img/404.png"; |
12 | | - |
13 | | -/** |
14 | | - * Property: originalOnImageLoadError |
15 | | - * {Function} Original onImageLoadError function. |
16 | | - */ |
17 | | -OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError; |
18 | | - |
19 | | -/** |
20 | | - * Function: onImageLoadError |
21 | | - */ |
22 | | -OpenLayers.Util.onImageLoadError = function() { |
23 | | - if (this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)) { |
24 | | - this.src = OpenLayers.Util.OSM.MISSING_TILE_URL; |
25 | | - } else if (this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)) { |
26 | | - // do nothing - this layer is transparent |
27 | | - } else { |
28 | | - OpenLayers.Util.OSM.originalOnImageLoadError; |
29 | | - } |
30 | | -}; |
31 | | - |
32 | | -/** |
33 | | - * @requires OpenLayers/Layer/TMS.js |
34 | | - * |
35 | | - * Class: OpenLayers.Layer.OSM |
36 | | - * |
37 | | - * Inherits from: |
38 | | - * - <OpenLayers.Layer.TMS> |
39 | | - */ |
40 | | -OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.TMS, { |
41 | | - /** |
42 | | - * Constructor: OpenLayers.Layer.OSM |
43 | | - * |
44 | | - * Parameters: |
45 | | - * name - {String} |
46 | | - * url - {String} |
47 | | - * options - {Object} Hashtable of extra options to tag onto the layer |
48 | | - */ |
49 | | - initialize: function(name, url, options) { |
50 | | - options = OpenLayers.Util.extend({ |
51 | | - attribution: "Data by <a href='http://openstreetmap.org/'>OpenStreetMap</a>", |
52 | | - maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), |
53 | | - maxResolution: 156543.0339, |
54 | | - units: "m", |
55 | | - projection: "EPSG:900913", |
56 | | - transitionEffect: "resize" |
57 | | - }, options); |
58 | | - var newArguments = [name, url, options]; |
59 | | - OpenLayers.Layer.TMS.prototype.initialize.apply(this, newArguments); |
60 | | - }, |
61 | | - |
62 | | - /** |
63 | | - * Method: getUrl |
64 | | - * |
65 | | - * Parameters: |
66 | | - * bounds - {<OpenLayers.Bounds>} |
67 | | - * |
68 | | - * Returns: |
69 | | - * {String} A string with the layer's url and parameters and also the |
70 | | - * passed-in bounds and appropriate tile size specified as |
71 | | - * parameters |
72 | | - */ |
73 | | - getURL: function (bounds) { |
74 | | - var res = this.map.getResolution(); |
75 | | - var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); |
76 | | - var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); |
77 | | - var z = this.map.getZoom(); |
78 | | - var limit = Math.pow(2, z); |
79 | | - |
80 | | - if (y < 0 || y >= limit) |
81 | | - { |
82 | | - return OpenLayers.Util.OSM.MISSING_TILE_URL; |
83 | | - } |
84 | | - else |
85 | | - { |
86 | | - x = ((x % limit) + limit) % limit; |
87 | | - |
88 | | - var url = this.url; |
89 | | - var path = z + "/" + x + "/" + y + ".png"; |
90 | | - |
91 | | - if (url instanceof Array) |
92 | | - { |
93 | | - url = this.selectUrl(path, url); |
94 | | - } |
95 | | - |
96 | | - return url + path; |
97 | | - } |
98 | | - }, |
99 | | - |
100 | | - CLASS_NAME: "OpenLayers.Layer.OSM" |
101 | | -}); |
102 | | - |
103 | | -/** |
104 | | - * Class: OpenLayers.Layer.OSM.Mapnik |
105 | | - * |
106 | | - * Inherits from: |
107 | | - * - <OpenLayers.Layer.OSM> |
108 | | - */ |
109 | | -OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, { |
110 | | - /** |
111 | | - * Constructor: OpenLayers.Layer.OSM.Mapnik |
112 | | - * |
113 | | - * Parameters: |
114 | | - * name - {String} |
115 | | - * options - {Object} Hashtable of extra options to tag onto the layer |
116 | | - */ |
117 | | - initialize: function(name, options) { |
118 | | - var url = [ |
119 | | - "http://a.tile.openstreetmap.org/", |
120 | | - "http://b.tile.openstreetmap.org/", |
121 | | - "http://c.tile.openstreetmap.org/" |
122 | | - ]; |
123 | | - options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options); |
124 | | - var newArguments = [name, url, options]; |
125 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
126 | | - }, |
127 | | - |
128 | | - CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik" |
129 | | -}); |
130 | | - |
131 | | -/** |
132 | | - * Class: OpenLayers.Layer.OSM.Osmarender |
133 | | - * |
134 | | - * Inherits from: |
135 | | - * - <OpenLayers.Layer.OSM> |
136 | | - */ |
137 | | -OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, { |
138 | | - /** |
139 | | - * Constructor: OpenLayers.Layer.OSM.Osmarender |
140 | | - * |
141 | | - * Parameters: |
142 | | - * name - {String} |
143 | | - * options - {Object} Hashtable of extra options to tag onto the layer |
144 | | - */ |
145 | | - initialize: function(name, options) { |
146 | | - var url = [ |
147 | | - "http://a.tah.openstreetmap.org/Tiles/tile/", |
148 | | - "http://b.tah.openstreetmap.org/Tiles/tile/", |
149 | | - "http://c.tah.openstreetmap.org/Tiles/tile/" |
150 | | - ]; |
151 | | - options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options); |
152 | | - var newArguments = [name, url, options]; |
153 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
154 | | - }, |
155 | | - |
156 | | - CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender" |
157 | | -}); |
158 | | - |
159 | | -/** |
160 | | - * Class: OpenLayers.Layer.OSM.CycleMap |
161 | | - * |
162 | | - * Inherits from: |
163 | | - * - <OpenLayers.Layer.OSM> |
164 | | - */ |
165 | | -OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, { |
166 | | - /** |
167 | | - * Constructor: OpenLayers.Layer.OSM.CycleMap |
168 | | - * |
169 | | - * Parameters: |
170 | | - * name - {String} |
171 | | - * options - {Object} Hashtable of extra options to tag onto the layer |
172 | | - */ |
173 | | - initialize: function(name, options) { |
174 | | - var url = [ |
175 | | - "http://a.thunderflames.org/tiles/cycle/", |
176 | | - "http://b.thunderflames.org/tiles/cycle/", |
177 | | - "http://c.thunderflames.org/tiles/cycle/" |
178 | | - ]; |
179 | | - options = OpenLayers.Util.extend({ numZoomLevels: 17 }, options); |
180 | | - var newArguments = [name, url, options]; |
181 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
182 | | - }, |
183 | | - |
184 | | - CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap" |
185 | | -}); |
186 | | - |
187 | | -/** |
188 | | - * Class: OpenLayers.Layer.OSM.Maplint |
189 | | - * |
190 | | - * Inherits from: |
191 | | - * - <OpenLayers.Layer.OSM> |
192 | | - */ |
193 | | -OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, { |
194 | | - /** |
195 | | - * Constructor: OpenLayers.Layer.OSM.Maplint |
196 | | - * |
197 | | - * Parameters: |
198 | | - * name - {String} |
199 | | - * options - {Object} Hashtable of extra options to tag onto the layer |
200 | | - */ |
201 | | - initialize: function(name, options) { |
202 | | - var url = [ |
203 | | - "http://d.tah.openstreetmap.org/Tiles/maplint/", |
204 | | - "http://e.tah.openstreetmap.org/Tiles/maplint/", |
205 | | - "http://f.tah.openstreetmap.org/Tiles/maplint/" |
206 | | - ]; |
207 | | - options = OpenLayers.Util.extend({ numZoomLevels: 18, isBaseLayer: false, visibility: false }, options); |
208 | | - var newArguments = [name, url, options]; |
209 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
210 | | - }, |
211 | | - |
212 | | - CLASS_NAME: "OpenLayers.Layer.OSM.Maplint" |
213 | | -}); |
214 | | - |
215 | | -osm_fully_loaded = true; |