[PLUGINS] +clavettes et dependances
[lhc/web/clavette_www.git] / www / plugins / gis / lib / leaflet / plugins / leaflet-providers.js
1 (function () {
2 'use strict';
3
4 L.TileLayer.Provider = L.TileLayer.extend({
5 initialize: function (arg, options) {
6 var providers = L.TileLayer.Provider.providers;
7
8 var parts = arg.split('.');
9
10 var providerName = parts[0];
11 var variantName = parts[1];
12
13 if (!providers[providerName]) {
14 throw 'No such provider (' + providerName + ')';
15 }
16
17 var provider = {
18 url: providers[providerName].url,
19 options: providers[providerName].options
20 };
21
22 // overwrite values in provider from variant.
23 if (variantName && 'variants' in providers[providerName]) {
24 if (!(variantName in providers[providerName].variants)) {
25 throw 'No such variant of ' + providerName + ' (' + variantName + ')';
26 }
27 var variant = providers[providerName].variants[variantName];
28 var variantOptions;
29 if (typeof variant === 'string') {
30 variantOptions = {
31 variant: variant
32 };
33 } else {
34 variantOptions = variant.options;
35 }
36 provider = {
37 url: variant.url || provider.url,
38 options: L.Util.extend({}, provider.options, variantOptions)
39 };
40 } else if (typeof provider.url === 'function') {
41 provider.url = provider.url(parts.splice(1, parts.length - 1).join('.'));
42 }
43
44 // replace attribution placeholders with their values from toplevel provider attribution,
45 // recursively
46 var attributionReplacer = function (attr) {
47 if (attr.indexOf('{attribution.') === -1) {
48 return attr;
49 }
50 return attr.replace(/\{attribution.(\w*)\}/,
51 function (match, attributionName) {
52 return attributionReplacer(providers[attributionName].options.attribution);
53 }
54 );
55 };
56 provider.options.attribution = attributionReplacer(provider.options.attribution);
57
58 // Compute final options combining provider options with any user overrides
59 var layerOpts = L.Util.extend({}, provider.options, options);
60 L.TileLayer.prototype.initialize.call(this, provider.url, layerOpts);
61 }
62 });
63
64 /**
65 * Definition of providers.
66 * see http://leafletjs.com/reference.html#tilelayer for options in the options map.
67 */
68
69 //jshint maxlen:220
70 L.TileLayer.Provider.providers = {
71 OpenStreetMap: {
72 url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
73 options: {
74 attribution:
75 '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
76 },
77 variants: {
78 Mapnik: {},
79 BlackAndWhite: {
80 url: 'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png'
81 },
82 DE: {
83 url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png'
84 },
85 HOT: {
86 url: 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
87 options: {
88 attribution: '{attribution.OpenStreetMap}, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
89 }
90 }
91 }
92 },
93 OpenSeaMap: {
94 url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
95 options: {
96 attribution: 'Map data: &copy; <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
97 }
98 },
99 Thunderforest: {
100 url: 'http://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png',
101 options: {
102 attribution:
103 '&copy; <a href="http://www.opencyclemap.org">OpenCycleMap</a>, {attribution.OpenStreetMap}',
104 variant: 'cycle'
105 },
106 variants: {
107 OpenCycleMap: 'cycle',
108 Transport: 'transport',
109 Landscape: 'landscape',
110 Outdoors: 'outdoors'
111 }
112 },
113 OpenMapSurfer: {
114 url: 'http://openmapsurfer.uni-hd.de/tiles/{variant}/x={x}&y={y}&z={z}',
115 options: {
116 minZoom: 0,
117 maxZoom: 20,
118 variant: 'roads',
119 attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data {attribution.OpenStreetMap}'
120 },
121 variants: {
122 Roads: 'roads',
123 AdminBounds: {
124 options: {
125 variant: 'adminb',
126 maxZoom: 19
127 }
128 },
129 Grayscale: {
130 options: {
131 variant: 'roadsg',
132 maxZoom: 19
133 }
134 }
135 }
136 },
137 Hydda: {
138 url: 'http://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png',
139 options: {
140 minZoom: 0,
141 maxZoom: 18,
142 variant: 'full',
143 attribution: 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">OpenStreetMap Sweden</a> &mdash; Map data {attribution.OpenStreetMap}'
144 },
145 variants: {
146 Full: 'full',
147 Base: 'base',
148 RoadsAndLabels: 'roads_and_labels',
149 }
150 },
151 MapQuestOpen: {
152 url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg',
153 options: {
154 attribution:
155 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
156 'Map data {attribution.OpenStreetMap}',
157 subdomains: '1234'
158 },
159 variants: {
160 OSM: {},
161 Aerial: {
162 url: 'http://oatile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',
163 options: {
164 attribution:
165 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
166 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency'
167 }
168 }
169 }
170 },
171 MapBox: {
172 url: function (id) {
173 return 'http://{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png';
174 },
175 options: {
176 attribution:
177 'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> &mdash; ' +
178 'Map data {attribution.OpenStreetMap}',
179 subdomains: 'abcd'
180 }
181 },
182 Stamen: {
183 url: 'http://{s}.tile.stamen.com/{variant}/{z}/{x}/{y}.png',
184 options: {
185 attribution:
186 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
187 '<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; ' +
188 'Map data {attribution.OpenStreetMap}',
189 subdomains: 'abcd',
190 minZoom: 0,
191 maxZoom: 20,
192 variant: 'toner'
193 },
194 variants: {
195 Toner: 'toner',
196 TonerBackground: 'toner-background',
197 TonerHybrid: 'toner-hybrid',
198 TonerLines: 'toner-lines',
199 TonerLabels: 'toner-labels',
200 TonerLite: 'toner-lite',
201 Terrain: {
202 options: {
203 variant: 'terrain',
204 minZoom: 4,
205 maxZoom: 18
206 }
207 },
208 TerrainBackground: {
209 options: {
210 variant: 'terrain-background',
211 minZoom: 4,
212 maxZoom: 18
213 }
214 },
215 Watercolor: {
216 options: {
217 variant: 'watercolor',
218 minZoom: 1,
219 maxZoom: 16
220 }
221 }
222 }
223 },
224 Esri: {
225 url: 'http://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}',
226 options: {
227 variant: 'World_Street_Map',
228 attribution: 'Tiles &copy; Esri'
229 },
230 variants: {
231 WorldStreetMap: {
232 options: {
233 attribution:
234 '{attribution.Esri} &mdash; ' +
235 'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
236 }
237 },
238 DeLorme: {
239 options: {
240 variant: 'Specialty/DeLorme_World_Base_Map',
241 minZoom: 1,
242 maxZoom: 11,
243 attribution: '{attribution.Esri} &mdash; Copyright: &copy;2012 DeLorme'
244 }
245 },
246 WorldTopoMap: {
247 options: {
248 variant: 'World_Topo_Map',
249 attribution:
250 '{attribution.Esri} &mdash; ' +
251 'Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community'
252 }
253 },
254 WorldImagery: {
255 options: {
256 variant: 'World_Imagery',
257 attribution:
258 '{attribution.Esri} &mdash; ' +
259 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
260 }
261 },
262 WorldTerrain: {
263 options: {
264 variant: 'World_Terrain_Base',
265 maxZoom: 13,
266 attribution:
267 '{attribution.Esri} &mdash; ' +
268 'Source: USGS, Esri, TANA, DeLorme, and NPS'
269 }
270 },
271 WorldShadedRelief: {
272 options: {
273 variant: 'World_Shaded_Relief',
274 maxZoom: 13,
275 attribution: '{attribution.Esri} &mdash; Source: Esri'
276 }
277 },
278 WorldPhysical: {
279 options: {
280 variant: 'World_Physical_Map',
281 maxZoom: 8,
282 attribution: '{attribution.Esri} &mdash; Source: US National Park Service'
283 }
284 },
285 OceanBasemap: {
286 options: {
287 variant: 'Ocean_Basemap',
288 maxZoom: 13,
289 attribution: '{attribution.Esri} &mdash; Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri'
290 }
291 },
292 NatGeoWorldMap: {
293 options: {
294 variant: 'NatGeo_World_Map',
295 maxZoom: 16,
296 attribution: '{attribution.Esri} &mdash; National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
297 }
298 },
299 WorldGrayCanvas: {
300 options: {
301 variant: 'Canvas/World_Light_Gray_Base',
302 maxZoom: 16,
303 attribution: '{attribution.Esri} &mdash; Esri, DeLorme, NAVTEQ'
304 }
305 }
306 }
307 },
308 OpenWeatherMap: {
309 url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png',
310 options: {
311 attribution: 'Map data &copy; <a href="http://openweathermap.org">OpenWeatherMap</a>',
312 opacity: 0.5
313 },
314 variants: {
315 Clouds: 'clouds',
316 CloudsClassic: 'clouds_cls',
317 Precipitation: 'precipitation',
318 PrecipitationClassic: 'precipitation_cls',
319 Rain: 'rain',
320 RainClassic: 'rain_cls',
321 Pressure: 'pressure',
322 PressureContour: 'pressure_cntr',
323 Wind: 'wind',
324 Temperature: 'temp',
325 Snow: 'snow'
326 }
327 },
328 HERE: {
329 /*
330 * HERE maps, formerly Nokia maps.
331 * These basemaps are free, but you need an API key. Please sign up at
332 * http://developer.here.com/getting-started
333 *
334 * Note that the base urls contain '.cit' whichs is HERE's
335 * 'Customer Integration Testing' environment. Please remove for production
336 * envirionments.
337 */
338 url:
339 'http://{s}.{base}.maps.cit.api.here.com/maptile/2.1/' +
340 'maptile/{mapID}/{variant}/{z}/{x}/{y}/256/png8?' +
341 'app_id={app_id}&app_code={app_code}',
342 options: {
343 attribution:
344 'Map &copy; 1987-2014 <a href="http://developer.here.com">HERE</a>',
345 subdomains: '1234',
346 mapID: 'newest',
347 'app_id': '<insert your app_id here>',
348 'app_code': '<insert your app_code here>',
349 base: 'base',
350 variant: 'normal.day',
351 minZoom: 0,
352 maxZoom: 20
353 },
354 variants: {
355 normalDay: 'normal.day',
356 normalDayCustom: 'normal.day.custom',
357 normalDayGrey: 'normal.day.grey',
358 normalDayMobile: 'normal.day.mobile',
359 normalDayGreyMobile: 'normal.day.grey.mobile',
360 normalDayTransit: 'normal.day.transit',
361 normalDayTransitMobile: 'normal.day.transit.mobile',
362 normalNight: 'normal.night',
363 normalNightMobile: 'normal.night.mobile',
364 normalNightGrey: 'normal.night.grey',
365 normalNightGreyMobile: 'normal.night.grey.mobile',
366
367 carnavDayGrey: 'carnav.day.grey',
368 hybridDay: {
369 options: {
370 base: 'aerial',
371 variant: 'hybrid.day'
372 }
373 },
374 hybridDayMobile: {
375 options: {
376 base: 'aerial',
377 variant: 'hybrid.day.mobile'
378 }
379 },
380 pedestrianDay: 'pedestrian.day',
381 pedestrianNight: 'pedestrian.night',
382 satelliteDay: {
383 options: {
384 base: 'aerial',
385 variant: 'satellite.day'
386 }
387 },
388 terrainDay: {
389 options: {
390 base: 'aerial',
391 variant: 'terrain.day'
392 }
393 },
394 terrainDayMobile: {
395 options: {
396 base: 'aerial',
397 variant: 'terrain.day.mobile'
398 }
399 }
400 }
401 },
402 Acetate: {
403 url: 'http://a{s}.acetate.geoiq.com/tiles/{variant}/{z}/{x}/{y}.png',
404 options: {
405 attribution:
406 '&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
407 subdomains: '0123',
408 minZoom: 2,
409 maxZoom: 18,
410 variant: 'acetate-base'
411 },
412 variants: {
413 basemap: 'acetate-base',
414 terrain: 'terrain',
415 all: 'acetate-hillshading',
416 foreground: 'acetate-fg',
417 roads: 'acetate-roads',
418 labels: 'acetate-labels',
419 hillshading: 'hillshading'
420 }
421 },
422 FreeMapSK: {
423 url: 'http://{s}.freemap.sk/T/{z}/{x}/{y}.jpeg',
424 options: {
425 minZoom: 8,
426 maxZoom: 16,
427 subdomains: ['t1', 't2', 't3', 't4'],
428 attribution:
429 '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 <a href="http://freemap.sk">Freemap.sk</a>'
430 }
431 },
432 MtbMap: {
433 url: 'http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png',
434 options: {
435 attribution:
436 '{attribution.OpenStreetMap} &amp; USGS'
437 }
438 },
439 CartoDB: {
440 url: 'http://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}.png',
441 options: {
442 attribution: '{attribution.OpenStreetMap} &copy; <a href="http://cartodb.com/attributions">CartoDB</a>',
443 subdomains: 'abcd',
444 minZoom: 0,
445 maxZoom: 18,
446 variant: 'light_all'
447 },
448 variants: {
449 Positron: 'light_all',
450 PositronNoLabels: 'light_nolabels',
451 DarkMatter: 'dark_all',
452 DarkMatterNoLabels: 'dark_nolabels'
453 }
454 }
455 };
456
457 L.tileLayer.provider = function (provider, options) {
458 return new L.TileLayer.Provider(provider, options);
459 };
460 }());