]> git.openstreetmap.org Git - nominatim.git/blob - website/js/tiles.js
ignore railways, tunnels and bridges when reverse geocoding
[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 }, 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.MapQuestOpen
61  *
62  * Inherits from:
63  *  - <OpenLayers.Layer.OSM>
64  */
65 OpenLayers.Layer.OSM.MapQuestOpen = OpenLayers.Class(OpenLayers.Layer.OSM, {
66     /**
67      * Constructor: OpenLayers.Layer.OSM.MapQuestOpen
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://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
76             "http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
77             "http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
78             "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png"
79         ];
80         options = OpenLayers.Util.extend({ numZoomLevels: 19, buffer: 0 }, options);
81         var newArguments = [name, url, options];
82         OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
83     },
84
85     CLASS_NAME: "OpenLayers.Layer.OSM.MapQuestOpen"
86 });
87
88 /**
89  * Class: OpenLayers.Layer.OSM.Osmarender
90  *
91  * Inherits from:
92  *  - <OpenLayers.Layer.OSM>
93  */
94 OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
95     /**
96      * Constructor: OpenLayers.Layer.OSM.Osmarender
97      *
98      * Parameters:
99      * name - {String}
100      * options - {Object} Hashtable of extra options to tag onto the layer
101      */
102     initialize: function(name, options) {
103         var url = [
104             "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
105             "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
106             "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
107         ];
108         options = OpenLayers.Util.extend({ numZoomLevels: 18, buffer: 0 }, options);
109         var newArguments = [name, url, options];
110         OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
111     },
112
113     CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
114 });
115
116 /**
117  * Class: OpenLayers.Layer.OSM.CycleMap
118  *
119  * Inherits from:
120  *  - <OpenLayers.Layer.OSM>
121  */
122 OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
123     /**
124      * Constructor: OpenLayers.Layer.OSM.CycleMap
125      *
126      * Parameters:
127      * name - {String}
128      * options - {Object} Hashtable of extra options to tag onto the layer
129      */
130     initialize: function(name, options) {
131         var url = [
132             "http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
133             "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
134             "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"
135         ];
136         options = OpenLayers.Util.extend({ numZoomLevels: 19, buffer: 0 }, options);
137         var newArguments = [name, url, options];
138         OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
139     },
140
141     CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
142 });