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

Last change on this file since 9222 was 9189, checked in by rick, 14 years ago

Avoid hitting the OSM website all the time, use local caching. Makes development more easy as well.

File size: 5.7 KB
RevLine 
[9139]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 = [
[9189]47 "/website/osm-proxy/${z}/${x},${y}.png",
[9139]48 ];
49 options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
50 var newArguments = [name, url, options];
51 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
52 },
53
54 CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
55});
56
57/**
58 * Class: OpenLayers.Layer.OSM.Osmarender
59 *
60 * Inherits from:
61 * - <OpenLayers.Layer.OSM>
62 */
63OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
64 /**
65 * Constructor: OpenLayers.Layer.OSM.Osmarender
66 *
67 * Parameters:
68 * name - {String}
69 * options - {Object} Hashtable of extra options to tag onto the layer
70 */
71 initialize: function(name, options) {
72 var url = [
73 "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
74 "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
75 "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
76 ];
77 options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options);
78 var newArguments = [name, url, options];
79 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
80 },
81
82 CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
83});
84
85/**
86 * Class: OpenLayers.Layer.OSM.CycleMap
87 *
88 * Inherits from:
89 * - <OpenLayers.Layer.OSM>
90 */
91OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
92 /**
93 * Constructor: OpenLayers.Layer.OSM.CycleMap
94 *
95 * Parameters:
96 * name - {String}
97 * options - {Object} Hashtable of extra options to tag onto the layer
98 */
99 initialize: function(name, options) {
100 var url = [
101 "http://a.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
102 "http://b.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
103 "http://c.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png"
104 ];
105 options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
106 var newArguments = [name, url, options];
107 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
108 },
109
110 CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
111});
112
113/**
114 * Class: OpenLayers.Layer.OSM.Maplint
115 *
116 * Inherits from:
117 * - <OpenLayers.Layer.OSM>
118 */
119OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, {
120 /**
121 * Constructor: OpenLayers.Layer.OSM.Maplint
122 *
123 * Parameters:
124 * name - {String}
125 * options - {Object} Hashtable of extra options to tag onto the layer
126 */
127 initialize: function(name, options) {
128 var url = [
129 "http://d.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
130 "http://e.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
131 "http://f.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png"
132 ];
133 options = OpenLayers.Util.extend({ numZoomLevels: 21, isBaseLayer: false, visibility: false }, options);
134 var newArguments = [name, url, options];
135 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
136 },
137
138 CLASS_NAME: "OpenLayers.Layer.OSM.Maplint"
139});
140
141
142OpenLayers.Layer.OSM.Overlay1 = OpenLayers.Class(OpenLayers.Layer.OSM, {
143 initialize: function(name, options) {
144 var url = [
145 "/gheat/classic/${z}/${x},${y}.png"
146 ];
147 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
148 var newArguments = [name, url, options];
149 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
150 },
151
152 CLASS_NAME: "OpenLayers.Layer.Overlay1"
153});
[9147]154
155OpenLayers.Layer.OSM.Overlay2 = OpenLayers.Class(OpenLayers.Layer.OSM, {
156 initialize: function(name, options) {
157 var url = [
[9166]158 "/website/tile/${z}/${x},${y}.png?colour=255,0,0"
[9147]159 ];
160 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
161 var newArguments = [name, url, options];
162 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
163 },
164
165 CLASS_NAME: "OpenLayers.Layer.Overlay2"
166});
[9166]167
168OpenLayers.Layer.OSM.Overlay3 = OpenLayers.Class(OpenLayers.Layer.OSM, {
169 initialize: function(name, options) {
170 var url = [
171 "/website/tile/${z}/${x},${y}.png?colour=0,0,255&accespoint__ssid__icontains=WirelessLeiden"
172 ];
173 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
174 var newArguments = [name, url, options];
175 OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
176 },
177
178 CLASS_NAME: "OpenLayers.Layer.Overlay3"
179});
Note: See TracBrowser for help on using the repository browser.