source: src/django_gheat/website/static/OpenStreetMap.js@ 9358

Last change on this file since 9358 was 9358, checked in by rick, 13 years ago

Starting to make production ready:

  • Remove all static / references.
  • Added multihost osm-proxy capacities.
  • Got the osm-proxy code to a more usefull location.
  • Added caching.
File size: 6.5 KB
Line 
1/**
2 * Namespace: Util.OSM
3 */
4OpenLayers.Util.OSM = {};
5
6/**
7 * Constant: MISSING_TILE_URL
8 * {String} URL of image to display for missing tiles
9 */
10OpenLayers.Util.OSM.MISSING_TILE_URL = "http://openstreetmap.org/openlayers/img/404.png";
11
12/**
13 * Property: originalOnImageLoadError
14 * {Function} Original onImageLoadError function.
15 */
16OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError;
17
18/**
19 * Function: onImageLoadError
20 */
21OpenLayers.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/**
32 * Class: OpenLayers.Layer.OSM.Mapnik
33 *
34 * Inherits from:
35 * - <OpenLayers.Layer.OSM>
36 */
37OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
38 /**
39 * Constructor: OpenLayers.Layer.OSM.Mapnik
40 *
41 * Parameters:
42 * name - {String}
43 * options - {Object} Hashtable of extra options to tag onto the layer
44 */
45 initialize: function(name, options) {
46 var url = [
47 "http://a.osmproxy.wirelessleiden.nl/heatmap/osm-proxy/${z}/${x},${y}.png",
48 "http://b.osmproxy.wirelessleiden.nl/heatmap/osm-proxy/${z}/${x},${y}.png",
49 "http://c.osmproxy.wirelessleiden.nl/heatmap/osm-proxy/${z}/${x},${y}.png",
50 ];
51 options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
52 var newArguments = [name, url, options];
53 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
54 },
55
56 CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
57});
58
59/**
60 * Class: OpenLayers.Layer.OSM.Osmarender
61 *
62 * Inherits from:
63 * - <OpenLayers.Layer.OSM>
64 */
65OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
66 /**
67 * Constructor: OpenLayers.Layer.OSM.Osmarender
68 *
69 * Parameters:
70 * name - {String}
71 * options - {Object} Hashtable of extra options to tag onto the layer
72 */
73 initialize: function(name, options) {
74 var url = [
75 "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
76 "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
77 "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
78 ];
79 options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options);
80 var newArguments = [name, url, options];
81 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
82 },
83
84 CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
85});
86
87/**
88 * Class: OpenLayers.Layer.OSM.CycleMap
89 *
90 * Inherits from:
91 * - <OpenLayers.Layer.OSM>
92 */
93OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
94 /**
95 * Constructor: OpenLayers.Layer.OSM.CycleMap
96 *
97 * Parameters:
98 * name - {String}
99 * options - {Object} Hashtable of extra options to tag onto the layer
100 */
101 initialize: function(name, options) {
102 var url = [
103 "http://a.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
104 "http://b.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
105 "http://c.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png"
106 ];
107 options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
108 var newArguments = [name, url, options];
109 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
110 },
111
112 CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
113});
114
115/**
116 * Class: OpenLayers.Layer.OSM.Maplint
117 *
118 * Inherits from:
119 * - <OpenLayers.Layer.OSM>
120 */
121OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, {
122 /**
123 * Constructor: OpenLayers.Layer.OSM.Maplint
124 *
125 * Parameters:
126 * name - {String}
127 * options - {Object} Hashtable of extra options to tag onto the layer
128 */
129 initialize: function(name, options) {
130 var url = [
131 "http://d.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
132 "http://e.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
133 "http://f.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png"
134 ];
135 options = OpenLayers.Util.extend({ numZoomLevels: 21, isBaseLayer: false, visibility: false }, options);
136 var newArguments = [name, url, options];
137 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
138 },
139
140 CLASS_NAME: "OpenLayers.Layer.OSM.Maplint"
141});
142
143/**
144 * Gheat layer
145 */
146OpenLayers.Layer.OSM.Overlay1 = OpenLayers.Class(OpenLayers.Layer.OSM, {
147 initialize: function(name, options) {
148 var url = [
149 "/gheat/classic/${z}/${x},${y}.png"
150 ];
151 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
152 var newArguments = [name, url, options];
153 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
154 },
155 colour: "0,0,0",
156 CLASS_NAME: "OpenLayers.Layer.Overlay"
157});
158
159/**
160 * All accespoints
161 */
162OpenLayers.Layer.OSM.Overlay2 = OpenLayers.Class(OpenLayers.Layer.OSM, {
163 initialize: function(name, options) {
164 var url = [
165 "tile/${z}/${x},${y}.png?colour=90,90,90"
166 ];
167 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
168 var newArguments = [name, url, options];
169 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
170 },
171 colour: "90,90,90",
172 CLASS_NAME: "OpenLayers.Layer.Overlay"
173});
174
175/**
176 * Wireless Leiden nodes
177 */
178OpenLayers.Layer.OSM.Overlay3 = OpenLayers.Class(OpenLayers.Layer.OSM, {
179 initialize: function(name, options) {
180 var url = [
181 "tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__ssid__icontains=WirelessLeiden"
182 ];
183 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
184 var newArguments = [name, url, options];
185 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
186 },
187 colour: "255,0,0",
188 CLASS_NAME: "OpenLayers.Layer.Overlay"
189});
190
191/**
192 * Signal strength
193 */
194OpenLayers.Layer.OSM.Overlay4 = OpenLayers.Class(OpenLayers.Layer.OSM, {
195 initialize: function(name, options) {
196 var url = [
197 "tile/${z}/${x},${y}.png?colour=250,250,0&signaal__gte=0&signaal__lte=100"
198 ];
199 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
200 var newArguments = [name, url, options];
201 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
202 },
203 colour: "250,250,0",
204 CLASS_NAME: "OpenLayers.Layer.Overlay"
205});
Note: See TracBrowser for help on using the repository browser.