1 | /**
|
---|
2 | * Namespace: Util.OSM
|
---|
3 | */
|
---|
4 | OpenLayers.Util.OSM = {};
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Constant: MISSING_TILE_URL
|
---|
8 | * {String} URL of image to display for missing tiles
|
---|
9 | */
|
---|
10 | OpenLayers.Util.OSM.MISSING_TILE_URL = "http://openstreetmap.org/openlayers/img/404.png";
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Property: originalOnImageLoadError
|
---|
14 | * {Function} Original onImageLoadError function.
|
---|
15 | */
|
---|
16 | OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Function: onImageLoadError
|
---|
20 | */
|
---|
21 | OpenLayers.Util.onImageLoadError = function() {
|
---|
22 | if (this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)) {
|
---|
23 | this.src = OpenLayers.Util.OSM.MISSING_TILE_URL;
|
---|
24 | } else if (this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)) {
|
---|
25 | // do nothing - this layer is transparent
|
---|
26 | } else {
|
---|
27 | OpenLayers.Util.OSM.originalOnImageLoadError;
|
---|
28 | }
|
---|
29 | };
|
---|
30 |
|
---|
31 | function get_balanced_urls(prefix, balancers, suffix) {
|
---|
32 | var urls = [];
|
---|
33 | for (var i=0; i < balancers.length; i++) {
|
---|
34 | urls.push(prefix + balancers[i] + suffix);
|
---|
35 | };
|
---|
36 | return urls;
|
---|
37 | };
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Class: OpenLayers.Layer.OSM.Mapnik
|
---|
43 | *
|
---|
44 | * Inherits from:
|
---|
45 | * - <OpenLayers.Layer.OSM>
|
---|
46 | */
|
---|
47 | OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
48 | /**
|
---|
49 | * Constructor: OpenLayers.Layer.OSM.Mapnik
|
---|
50 | *
|
---|
51 | * Parameters:
|
---|
52 | * name - {String}
|
---|
53 | * options - {Object} Hashtable of extra options to tag onto the layer
|
---|
54 | */
|
---|
55 | initialize: function(name, options) {
|
---|
56 | var url = get_balanced_urls('http://', {{ settings.OSM_PROXY_CDN_DOMAINS|safe }}, '{{ settings.OSM_PREFIX }}/${z}/${x}/${y}.png');
|
---|
57 | options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
|
---|
58 | var newArguments = [name, url, options];
|
---|
59 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
60 | },
|
---|
61 |
|
---|
62 | CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
|
---|
63 | });
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Class: OpenLayers.Layer.OSM.Osmarender
|
---|
67 | *
|
---|
68 | * Inherits from:
|
---|
69 | * - <OpenLayers.Layer.OSM>
|
---|
70 | */
|
---|
71 | OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
72 | /**
|
---|
73 | * Constructor: OpenLayers.Layer.OSM.Osmarender
|
---|
74 | *
|
---|
75 | * Parameters:
|
---|
76 | * name - {String}
|
---|
77 | * options - {Object} Hashtable of extra options to tag onto the layer
|
---|
78 | */
|
---|
79 | initialize: function(name, options) {
|
---|
80 | var url = [
|
---|
81 | "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
|
---|
82 | "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
|
---|
83 | "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
|
---|
84 | ];
|
---|
85 | options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options);
|
---|
86 | var newArguments = [name, url, options];
|
---|
87 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
88 | },
|
---|
89 |
|
---|
90 | CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
|
---|
91 | });
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Class: OpenLayers.Layer.OSM.CycleMap
|
---|
95 | *
|
---|
96 | * Inherits from:
|
---|
97 | * - <OpenLayers.Layer.OSM>
|
---|
98 | */
|
---|
99 | OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
100 | /**
|
---|
101 | * Constructor: OpenLayers.Layer.OSM.CycleMap
|
---|
102 | *
|
---|
103 | * Parameters:
|
---|
104 | * name - {String}
|
---|
105 | * options - {Object} Hashtable of extra options to tag onto the layer
|
---|
106 | */
|
---|
107 | initialize: function(name, options) {
|
---|
108 | var url = [
|
---|
109 | "http://a.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
|
---|
110 | "http://b.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
|
---|
111 | "http://c.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png"
|
---|
112 | ];
|
---|
113 | options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
|
---|
114 | var newArguments = [name, url, options];
|
---|
115 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
116 | },
|
---|
117 |
|
---|
118 | CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
|
---|
119 | });
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Class: OpenLayers.Layer.OSM.Maplint
|
---|
123 | *
|
---|
124 | * Inherits from:
|
---|
125 | * - <OpenLayers.Layer.OSM>
|
---|
126 | */
|
---|
127 | OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
128 | /**
|
---|
129 | * Constructor: OpenLayers.Layer.OSM.Maplint
|
---|
130 | *
|
---|
131 | * Parameters:
|
---|
132 | * name - {String}
|
---|
133 | * options - {Object} Hashtable of extra options to tag onto the layer
|
---|
134 | */
|
---|
135 | initialize: function(name, options) {
|
---|
136 | var url = [
|
---|
137 | "http://d.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
|
---|
138 | "http://e.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
|
---|
139 | "http://f.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png"
|
---|
140 | ];
|
---|
141 | options = OpenLayers.Util.extend({ numZoomLevels: 21, isBaseLayer: false, visibility: false }, options);
|
---|
142 | var newArguments = [name, url, options];
|
---|
143 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
144 | },
|
---|
145 |
|
---|
146 | CLASS_NAME: "OpenLayers.Layer.OSM.Maplint"
|
---|
147 | });
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Gheat layer
|
---|
151 | */
|
---|
152 | OpenLayers.Layer.OSM.Overlay1 = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
153 | initialize: function(name, options) {
|
---|
154 | var url = [
|
---|
155 | "/gheat/classic/${z}/${x},${y}.png"
|
---|
156 | ];
|
---|
157 | options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
|
---|
158 | var newArguments = [name, url, options];
|
---|
159 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
160 | },
|
---|
161 | colour: "0,0,0",
|
---|
162 | CLASS_NAME: "OpenLayers.Layer.Overlay"
|
---|
163 | });
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * All accespoints
|
---|
167 | */
|
---|
168 | OpenLayers.Layer.OSM.Overlay2 = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
169 | initialize: function(name, options) {
|
---|
170 | var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
|
---|
171 | '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=90,90,90');
|
---|
172 | options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
|
---|
173 | var newArguments = [name, url, options];
|
---|
174 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
175 | },
|
---|
176 | colour: "90,90,90",
|
---|
177 | CLASS_NAME: "OpenLayers.Layer.Overlay"
|
---|
178 | });
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Wireless Leiden nodes
|
---|
182 | */
|
---|
183 | OpenLayers.Layer.OSM.Overlay3 = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
184 | initialize: function(name, options) {
|
---|
185 | var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
|
---|
186 | '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__organization=WirelessLeiden');
|
---|
187 | options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
|
---|
188 | var newArguments = [name, url, options];
|
---|
189 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
190 | },
|
---|
191 | colour: "255,0,0",
|
---|
192 | CLASS_NAME: "OpenLayers.Layer.Overlay"
|
---|
193 | });
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Signal strength
|
---|
197 | */
|
---|
198 | OpenLayers.Layer.OSM.Overlay4 = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
199 | initialize: function(name, options) {
|
---|
200 | var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
|
---|
201 | '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=50,150,50&signaal__gte=0&signaal__lte=100');
|
---|
202 | options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
|
---|
203 | var newArguments = [name, url, options];
|
---|
204 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
205 | },
|
---|
206 | colour: "50,150,50",
|
---|
207 | CLASS_NAME: "OpenLayers.Layer.Overlay"
|
---|
208 | });
|
---|