PageSourceSearch

https://www.flymidwales.org.uk/site/modules/FieldtypeLeafletMapMar…/leaflet-providers/leaflet-providers.js

js flymidwales.org.uk collected 2026-10-02 13:54:54 UTC 17,262 bytes, 604 lines download raw bytes

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			var forceHTTP = window.location.protocol === 'file:' || provider.options.forceHTTP;
45			if (provider.url.indexOf('//') === 0 && forceHTTP) {
46				provider.url = 'http:' + provider.url;
47			}
48
49			// replace attribution placeholders with their values from toplevel provider attribution,
50			// recursively
51			var attributionReplacer = function (attr) {
52				if (attr.indexOf('{attribution.') === -1) {
53					return attr;
54				}
55				return attr.replace(/\{attribution.(\w*)\}/,
56					function (match, attributionName) {
57						return attributionReplacer(providers[attributionName].options.attribution);
58					}
59				);
60			};
61			provider.options.attribution = attributionReplacer(provider.options.attribution);
62
63			// Compute final options combining provider options with any user overrides
64			var layerOpts = L.Util.extend({}, provider.options, options);
65			L.TileLayer.prototype.initialize.call(this, provider.url, layerOpts);
66		}
67	});
68
69	/**
70	 * Definition of providers.
71	 * see http://leafletjs.com/reference.html#tilelayer for options in the options map.
72	 */
73
74	L.TileLayer.Provider.providers = {
75		OpenStreetMap: {
76			url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
77			options: {
78				attribution:
79					'&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
80			},
81			variants: {
82				Mapnik: {},
83				BlackAndWhite: {
84					url: 'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png'
85				},
86				DE: {
87					url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png'
88				},
89				HOT: {
90					url: 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
91					options: {
92						attribution: '{attribution.OpenStreetMap}, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
93					}
94				}
95			}
96		},
97		OpenSeaMap: {
98			url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
99			options: {
100				attribution: 'Map data: &copy; <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
101			}
102		},
103		OpenTopoMap: {
104			url: '//{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
105			options: {
106				maxZoom: 16,
107				attribution: 'Map data: {attribution.OpenStreetMap}, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
108			}
109		},
110		Thunderforest: {
111			url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey=ddaa0e148a1d41c3a452b0ebedd6d3db',
112			options: {
113				attribution:
114					'&copy; <a href="http://www.opencyclemap.org">OpenCycleMap</a>, {attribution.OpenStreetMap}',
115				variant: 'cycle'
116			},
117			variants: {
118				OpenCycleMap: 'cycle',
119				Transport: 'transport',
120				TransportDark: 'transport-dark',
121				Landscape: 'landscape',
122				Outdoors: 'outdoors'
123			}
124		},
125		OpenMapSurfer: {
126			url: 'http://openmapsurfer.uni-hd.de/tiles/{variant}/x={x}&y={y}&z={z}',
127			options: {
128				minZoom: 0,
129				maxZoom: 20,
130				variant: 'roads',
131				attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data {attribution.OpenStreetMap}'
132			},
133			variants: {
134				Roads: 'roads',
135				AdminBounds: {
136					options: {
137						variant: 'adminb',
138						maxZoom: 19
139					}
140				},
141				Grayscale: {
142					options: {
143						variant: 'roadsg',
144						maxZoom: 19
145					}
146				}
147			}
148		},
149		Hydda: {
150			url: 'http://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png',
151			options: {
152				minZoom: 0,
153				maxZoom: 18,
154				variant: 'full',
155				attribution: 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">
155OpenStreetMap Sweden</a> &mdash; Map data {attribution.OpenStreetMap}'
156			},
157			variants: {
158				Full: 'full',
159				Base: 'base',
160				RoadsAndLabels: 'roads_and_labels'
161			}
162		},
163		MapQuestOpen: {
164			/* Mapquest does support https, but with a different subdomain:
165			 * https://otile{s}-s.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}
166			 * which makes implementing protocol relativity impossible.
167			 */
168			url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}',
169			options: {
170				type: 'map',
171				ext: 'jpg',
172				attribution:
173					'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
174					'Map data {attribution.OpenStreetMap}',
175				subdomains: '1234'
176			},
177			variants: {
178				OSM: {},
179				Aerial: {
180					options: {
181						type: 'sat',
182						attribution:
183							'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
184							'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency'
185					}
186				},
187				HybridOverlay: {
188					options: {
189						type: 'hyb',
190						ext: 'png',
191						opacity: 0.9
192					}
193				}
194			}
195		},
196		MapBox: {
197			url: function (id) {
198				return '//{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png';
199			},
200			options: {
201				attribution:
202					'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> &mdash; ' +
203					'Map data {attribution.OpenStreetMap}',
204				subdomains: 'abcd'
205			}
206		},
207		Stamen: {
208			url: 'http://{s}.tile.stamen.com/{variant}/{z}/{x}/{y}.{ext}',
209			options: {
210				attribution:
211					'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
212					'<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; ' +
213					'Map data {attribution.OpenStreetMap}',
214				subdomains: 'abcd',
215				minZoom: 0,
216				maxZoom: 20,
217				variant: 'toner',
218				ext: 'png'
219			},
220			variants: {
221				Toner: 'toner',
222				TonerBackground: 'toner-background',
223				TonerHybrid: 'toner-hybrid',
224				TonerLines: 'toner-lines',
225				TonerLabels: 'toner-labels',
226				TonerLite: 'toner-lite',
227				Watercolor: {
228					options: {
229						variant: 'watercolor',
230						minZoom: 1,
231						maxZoom: 16
232					}
233				},
234				Terrain: {
235					options: {
236						variant: 'terrain',
237						minZoom: 4,
238						maxZoom: 18,
239						bounds: [[22, -132], [70, -56]]
240					}
241				},
242				TerrainBackground: {
243					options: {
244						variant: 'terrain-background',
245						minZoom: 4,
246						maxZoom: 18,
247						bounds: [[22, -132], [70, -56]]
248					}
249				},
250				TopOSMRelief: {
251					options: {
252						variant: 'toposm-color-relief',
253						ext: 'jpg',
254						bounds: [[22, -132], [51, -56]]
255					}
256				},
257				TopOSMFeatures: {
258					options: {
259						variant: 'toposm-features',
260						bounds: [[22, -132], [51, -56]],
261						opacity: 0.9
262					}
263				}
264			}
265		},
266		Esri: {
267			url: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}',
268			options: {
269				variant: 'World_Street_Map',
270				attribution: 'Tiles &copy; Esri'
271			},
272			variants: {
273				WorldStreetMap: {
274					options: {
275						attribution:
276							'{attribution.Esri} &mdash; ' +
277							'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
278					}
279				},
280				DeLorme: {
281					options: {
282						variant: 'Specialty/DeLorme_World_Base_Map',
283						minZoom: 1,
284						maxZoom: 11,
285						attribution: '{attribution.Esri} &mdash; Copyright: &copy;2012 DeLorme'
286					}
287				},
288				WorldTopoMap: {
289					options: {
290						variant: 'World_Topo_Map',
291						attribution:
292							'{attribution.Esri} &mdash; ' +
293							'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'
294					}
295				},
296				WorldImagery: {
297					options: {
298						variant: 'World_Imagery',
299						attribution:
300							'{attribution.Esri} &mdash; ' +
301							'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
302					}
303				},
304				WorldTerrain: {
305					options: {
306						variant: 'World_Terrain_Base',
307						maxZoom: 13,
308						attribution:
309							'{attribution.Esri} &mdash; ' +
310							'Source: USGS, Esri, TANA, DeLorme, and NPS'
311					}
312				},
313				WorldShadedRelief: {
314					options: {
315						variant: 'World_Shaded_Relief',
316						maxZoom: 13,
317						attribution: '{attribution.Esri} &mdash; Source: Esri'
318					}
319				},
320				WorldPhysical: {
321					options: {
322						variant: 'World_Physical_Map',
323						maxZoom: 8,
324						attribution: '{attribution.Esri} &mdash; Source: US National Park Service'
325					}
326				},
327				OceanBasemap: {
328					options: {
329						variant: 'Ocean_Basemap',
330						maxZoom: 13,
331						attribution: '{attribution.Esri} &mdash; Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri'
332					}
333				},
334				NatGeoWorldMap: {
335					options: {
336						variant: 'NatGeo_World_Map',
337						maxZoom: 16,
338						attribution: '{attribution.Esri} &mdash; National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
339					}
340				},
341				WorldGrayCanvas: {
342					options: {
343						variant: 'Canvas/World_Light_Gray_Base',
344						maxZoom: 16,
345						attribution: '{attribution.Esri} &mdash; Esri, DeLorme, NAVTEQ'
346					}
347				}
348			}
349		},
350		OpenWeatherMap: {
351			url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png',
352			options: {
353				attribution: 'Map data &copy; <a href="http://openweathermap.org">OpenWeatherMap</a>',
354				opacity: 0.5
355			},
356			variants: {
357				Clouds: 'clouds',
358				CloudsClassic: 'clouds_cls',
359				Precipitation: 'precipitation',
360				PrecipitationClassic: 'precipitation_cls',
361				Rain: 'rain',
362				RainClassic: 'rain_cls',
363				Pressure: 'pressure',
364				PressureContour: 'pressure_cntr',
365				Wind: 'wind',
366				Temperature: 'temp',
367				Snow: 'snow'
368			}
369		},
370		HERE: {
371			/*
372			 * HERE maps, formerly Nokia maps.
373			 * These basemaps are free, but you need an API key. Please sign up at
374			 * http://developer.here.com/getting-started
375			 *
376			 * Note that the base urls contain '.cit' whichs is HERE's
377			 * 'Customer Integration Testing' environment. Please remove for production
378			 * envirionments.
379			 */
380			url:
381				'//{s}.{base}.maps.cit.api.here.com/maptile/2.1/' +
382				'maptile/{mapID}/{variant}/{z}/{x}/{y}/256/png8?' +
383				'app_id={app_id}&app_code={app_code}',
384			options: {
385				attribution:
386					'Map &copy; 1987-2014 <a href="http://developer.here.com">HERE</a>',
387				subdomains: '1234',
388				mapID: 'newest',
389				'app_id': '<insert your app_id here>',
390				'app_code': '<insert your app_code here>',
391				base: 'base',
392				variant: 'normal.day',
393				minZoom: 0,
394				maxZoom: 20
395			},
396			variants: {
397				normalDay: 'normal.day',
398				normalDayCustom: 'normal.day.custom',
399				normalDayGrey: 'normal.day.grey',
400				normalDayMobile: 'normal.day.mobile',
401				normalDayGreyMobile: 'normal.day.grey.mobile',
402				normalDayTransit: 'normal.day.transit',
403				normalDayTransitMobile: 'normal.day.transit.mobile',
404				normalNight: 'normal.night',
405				normalNightMobile: 'normal.night.mobile',
406				normalNightGrey: 'normal.night.grey',
407				normalNightGreyMobile: 'normal.night.grey.mobile',
408
409				carnavDayGrey: 'carnav.day.grey',
410				hybridDay: {
411					options: {
412						base: 'aerial',
413						variant: 'hybrid.day'
414					}
415				},
416				hybridDayMobile: {
417					options: {
418						base: 'aerial',
419						variant: 'hybrid.day.mobile'
420					}
421				},
422				pedestrianDay: 'pedestrian.day',
423				pedestrianNight: 'pedestrian.night',
424				satelliteDay: {
425					options: {
426						base: 'aerial',
427						variant: 'satellite.day'
428					}
429				},
430				terrainDay: {
431					options: {
432						base: 'aerial',
433						variant: 'terrain.day'
434					}
435				},
436				terrainDayMobile: {
437					options: {
438						base: 'aerial',
439						variant: 'terrain.day.mobile'
440					}
441				}
442			}
443		},
444		Acetate: {
445			url: 'http://a{s}.acetate.geoiq.com/tiles/{variant}/{z}/{x}/{y}.png',
446			options: {
447				attribution:
448					'&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
449				subdomains: '0123',
450				minZoom: 2,
451				maxZoom: 18,
452				variant: 'acetate-base'
453			},
454			variants: {
455				basemap: 'acetate-base',
456				terrain: 'terrain',
457				all: 'acetate-hillshading',
458				foreground: 'acetate-fg',
459				roads: 'acetate-roads',
460				labels: 'acetate-labels',
461				hillshading: 'hillshading'
462			}
463		},
464		FreeMapSK: {
465			url: 'http://{s}.freemap.sk/T/{z}/{x}/{y}.jpeg',
466			options: {
467				minZoom: 8,
468				maxZoom: 16,
469				subdomains: ['t1', 't2', 't3', 't4'],
470				attribution:
471					'{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 <a href="http://freemap.sk">Freemap.sk</a>'
472			}
473		},
474		MtbMap: {
475			url: 'http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png',
476			options: {
477				attribution:
478					'{attribution.OpenStreetMap} &amp; USGS'
479			}
480		},
481		CartoDB: {
482			url: 'http://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}.png',
483			options: {
484				attribution: '{attribution.OpenStreetMap} &copy; <a href="http://cartodb.com/attributions">CartoDB</a>',
485				subdomains: 'abcd',
486				minZoom: 0,
487				maxZoom: 18,
488				variant: 'light_all'
489			},
490			variants: {
491				Positron: 'light_all',
492				PositronNoLabels: 'light_nolabels',
493				DarkMatter: 'dark_all',
494				DarkMatterNoLabels: 'dark_nolabels'
495			}
496		},
497		HikeBike: {
498			url: 'http://{s}.tiles.wmflabs.org/hikebike/{z}/{x}/{y}.png',
499			options: {
500				attribution: '{attribution.OpenStreetMap}'
501			}
502		},
503		BasemapAT: {
504			url: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}',
505			options: {
506				attribution: 'Datenquelle: <a href="www.basemap.at">basemap.at</a>',
507				subdomains: ['', '1', '2', '3', '4'],
508				bounds: [[46.358770, 8.782379], [49.037872, 17.189532]]
509			},
510			variants: {
511				basemap: {
512					options: {
513						variant: 'geolandbasemap',
514						format: 'jpeg'
515					}
516				},
517				highdpi: {
518					options: {
519						variant: 'bmaphidpi',
520						format: 'jpeg'
521					}
522				},
523				grau: {
524					options: {
525						variant: 'bmapgrau',
526						format: 'png'
527					}
528				},
529				overlay: {
530					options: {
531						variant: 'bmapoverlay',
532						format: 'png'
533					}
534				},
535				orthofoto: {
536					options: {
537						variant: 'bmaporthofoto30cm',
538						format: 'jpeg'
539					}
540				}
541			}
542		},
543		NASAGIBS: {
544			url: '//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}',
545			options: {
546				attribution:
547					'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' +
548					'(<a href="https://earthdata.nasa.gov">ESDIS</a>) with funding provided by NASA/HQ.',
549				bounds: [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]],
550				minZoom: 1,
551				maxZoom: 9,
552				format: 'jpg',
553				time: '',
554				tilematrixset: 'GoogleMapsCompatible_Level'
555			},
556			variants: {
557				ModisTerraTrueColorCR: 'MODIS_Terra_CorrectedReflectance_True
557Color',
558				ModisTerraBands367CR: 'MODIS_Terra_CorrectedReflectance_Bands367',
559				ViirsEarthAtNight2012: {
560					options: {
561						variant: 'VIIRS_CityLights_2012',
562						maxZoom: 8
563					}
564				},
565				ModisTerraLSTDay: {
566					options: {
567						variant: 'MODIS_Terra_Land_Surface_Temp_Day',
568						format: 'png',
569						maxZoom: 7,
570						opacity: 0.75
571					}
572				},
573				ModisTerraSnowCover: {
574					options: {
575						variant: 'MODIS_Terra_Snow_Cover',
576						format: 'png',
577						maxZoom: 8,
578						opacity: 0.75
579					}
580				},
581				ModisTerraAOD: {
582					options: {
583						variant: 'MODIS_Terra_Aerosol',
584						format: 'png',
585						maxZoom: 6,
586						opacity: 0.75
587					}
588				},
589				ModisTerraChlorophyll: {
590					options: {
591						variant: 'MODIS_Terra_Chlorophyll_A',
592						format: 'png',
593						maxZoom: 7,
594						opacity: 0.75
595					}
596				}
597			}
598		}
599	};
600
601	L.tileLayer.provider = function (provider, options) {
602		return new L.TileLayer.Provider(provider, options);
603	};
604}());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.