]> git.openstreetmap.org Git - nominatim.git/blob - website/js/tiles.js
Remove stray exit from debug
[nominatim.git] / website / js / tiles.js
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://www.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 /**
32  * Class: OpenLayers.Layer.OSM.Mapnik
33  *
34  * Inherits from:
35  *  - <OpenLayers.Layer.OSM>
36  */
37 OpenLayers.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.tile.openstreetmap.org/${z}/${x}/${y}.png",
48             "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
49             "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
50         ];
51         options = OpenLayers.Util.extend({ numZoomLevels: 19, buffer: 0,
52            attribution : '© <a target="_parent" href="http://www.openstreetmap.org">OpenStreetMap</a> and contributors, under an <a target="_parent" href="http://www.openstreetmap.org/copyright">open license</a>' }, options);
53         var newArguments = [name, url, options];
54         OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
55     },
56
57     CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
58 });
59
60 /**
61  * Class: OpenLayers.Layer.OSM.MapQuestOpen
62  *
63  * Inherits from:
64  *  - <OpenLayers.Layer.OSM>
65  */
66 OpenLayers.Layer.OSM.MapQuestOpen = OpenLayers.Class(OpenLayers.Layer.OSM, {
67     /**
68      * Constructor: OpenLayers.Layer.OSM.MapQuestOpen
69      *
70      * Parameters:
71      * name - {String}
72      * options - {Object} Hashtable of extra options to tag onto the layer
73      */
74     initialize: function(name, options) {
75         var url = [
76             "http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
77             "http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
78             "http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
79             "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png"
80         ];
81         options = OpenLayers.Util.extend({ numZoomLevels: 19, buffer: 0 }, options);
82         var newArguments = [name, url, options];
83         OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
84     },
85
86     CLASS_NAME: "OpenLayers.Layer.OSM.MapQuestOpen"
87 });
88
89 /**
90  * Class: OpenLayers.Layer.OSM.CycleMap
91  *
92  * Inherits from:
93  *  - <OpenLayers.Layer.OSM>
94  */
95 OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
96     /**
97      * Constructor: OpenLayers.Layer.OSM.CycleMap
98      *
99      * Parameters:
100      * name - {String}
101      * options - {Object} Hashtable of extra options to tag onto the layer
102      */
103     initialize: function(name, options) {
104         var url = [
105             "http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
106             "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
107             "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"
108         ];
109         options = OpenLayers.Util.extend({ numZoomLevels: 19, buffer: 0 }, options);
110         var newArguments = [name, url, options];
111         OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
112     },
113
114     CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
115 });