1 (function (root
, factory
) {
2 if (typeof define
=== 'function' && define
.amd
) {
3 // AMD. Register as an anonymous module.
4 define(['leaflet'], factory
);
5 } else if (typeof modules
=== 'object' && module
.exports
) {
6 // define a Common JS module that relies on 'leaflet'
7 module
.exports
= factory(require('leaflet'));
9 // Assume Leaflet is loaded into global object L already
12 }(this, function (L
) {
15 L
.TileLayer
.Provider
= L
.TileLayer
.extend({
16 initialize: function (arg
, options
) {
17 var providers
= L
.TileLayer
.Provider
.providers
;
19 var parts
= arg
.split('.');
21 var providerName
= parts
[0];
22 var variantName
= parts
[1];
24 if (!providers
[providerName
]) {
25 throw 'No such provider (' + providerName
+ ')';
29 url
: providers
[providerName
].url
,
30 options
: providers
[providerName
].options
33 // overwrite values in provider from variant.
34 if (variantName
&& 'variants' in providers
[providerName
]) {
35 if (!(variantName
in providers
[providerName
].variants
)) {
36 throw 'No such variant of ' + providerName
+ ' (' + variantName
+ ')';
38 var variant
= providers
[providerName
].variants
[variantName
];
40 if (typeof variant
=== 'string') {
45 variantOptions
= variant
.options
;
48 url
: variant
.url
|| provider
.url
,
49 options
: L
.Util
.extend({}, provider
.options
, variantOptions
)
53 var forceHTTP
= window
.location
.protocol
=== 'file:' || provider
.options
.forceHTTP
;
54 if (provider
.url
.indexOf('//') === 0 && forceHTTP
) {
55 provider
.url
= 'http:' + provider
.url
;
58 // If retina option is set
59 if (provider
.options
.retina
) {
60 // Check retina screen
61 if (options
.detectRetina
&& L
.Browser
.retina
) {
62 // The retina option will be active now
63 // But we need to prevent Leaflet retina mode
64 options
.detectRetina
= false;
66 // No retina, remove option
67 provider
.options
.retina
= '';
71 // replace attribution placeholders with their values from toplevel provider attribution,
73 var attributionReplacer = function (attr
) {
74 if (attr
.indexOf('{attribution.') === -1) {
77 return attr
.replace(/\{attribution.(\w*)\}/,
78 function (match
, attributionName
) {
79 return attributionReplacer(providers
[attributionName
].options
.attribution
);
83 provider
.options
.attribution
= attributionReplacer(provider
.options
.attribution
);
85 // Compute final options combining provider options with any user overrides
86 var layerOpts
= L
.Util
.extend({}, provider
.options
, options
);
87 L
.TileLayer
.prototype.initialize
.call(this, provider
.url
, layerOpts
);
92 * Definition of providers.
93 * see http://leafletjs.com/reference.html#tilelayer for options in the options map.
96 L
.TileLayer
.Provider
.providers
= {
98 url
: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
102 '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
107 url
: 'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png',
113 url
: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png',
119 url
: '//{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png',
122 attribution
: '© Openstreetmap France | {attribution.OpenStreetMap}'
126 url
: '//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
128 attribution
: '{attribution.OpenStreetMap}, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
134 url
: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
136 attribution
: 'Map data: © <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
140 url
: '//{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
143 attribution
: 'Map data: {attribution.OpenStreetMap}, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
147 url
: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png',
150 '© <a href="http://www.thunderforest.com/">Thunderforest</a>, {attribution.OpenStreetMap}',
154 OpenCycleMap
: 'cycle',
157 variant
: 'transport',
163 variant
: 'transport-dark',
169 variant
: 'spinal-map',
173 Landscape
: 'landscape',
174 Outdoors
: 'outdoors',
179 url
: 'http://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}',
183 attribution
: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> — Map data {attribution.OpenStreetMap}'
202 url
: '//{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png',
205 attribution
: 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">OpenStreetMap Sweden</a> — Map data {attribution.OpenStreetMap}'
210 RoadsAndLabels
: 'roads_and_labels'
214 url
: '//api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}',
217 'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> — ' +
218 'Map data {attribution.OpenStreetMap}',
223 url
: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}',
226 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
227 '<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — ' +
228 'Map data {attribution.OpenStreetMap}',
237 TonerBackground
: 'toner-background',
238 TonerHybrid
: 'toner-hybrid',
239 TonerLines
: 'toner-lines',
240 TonerLabels
: 'toner-labels',
241 TonerLite
: 'toner-lite',
244 variant
: 'watercolor',
258 variant
: 'terrain-background',
265 variant
: 'toposm-color-relief',
267 bounds
: [[22, -132], [51, -56]]
272 variant
: 'toposm-features',
273 bounds
: [[22, -132], [51, -56]],
280 url
: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}',
282 variant
: 'World_Street_Map',
283 attribution
: 'Tiles © Esri'
289 '{attribution.Esri} — ' +
290 'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
295 variant
: 'Specialty/DeLorme_World_Base_Map',
298 attribution
: '{attribution.Esri} — Copyright: ©2012 DeLorme'
303 variant
: 'World_Topo_Map',
305 '{attribution.Esri} — ' +
306 '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'
311 variant
: 'World_Imagery',
313 '{attribution.Esri} — ' +
314 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
319 variant
: 'World_Terrain_Base',
322 '{attribution.Esri} — ' +
323 'Source: USGS, Esri, TANA, DeLorme, and NPS'
328 variant
: 'World_Shaded_Relief',
330 attribution
: '{attribution.Esri} — Source: Esri'
335 variant
: 'World_Physical_Map',
337 attribution
: '{attribution.Esri} — Source: US National Park Service'
342 variant
: 'Ocean_Basemap',
344 attribution
: '{attribution.Esri} — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri'
349 variant
: 'NatGeo_World_Map',
351 attribution
: '{attribution.Esri} — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
356 variant
: 'Canvas/World_Light_Gray_Base',
358 attribution
: '{attribution.Esri} — Esri, DeLorme, NAVTEQ'
364 url
: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png',
367 attribution
: 'Map data © <a href="http://openweathermap.org">OpenWeatherMap</a>',
372 CloudsClassic
: 'clouds_cls',
373 Precipitation
: 'precipitation',
374 PrecipitationClassic
: 'precipitation_cls',
376 RainClassic
: 'rain_cls',
377 Pressure
: 'pressure',
378 PressureContour
: 'pressure_cntr',
386 * HERE maps, formerly Nokia maps.
387 * These basemaps are free, but you need an API key. Please sign up at
388 * http://developer.here.com/getting-started
390 * Note that the base urls contain '.cit' whichs is HERE's
391 * 'Customer Integration Testing' environment. Please remove for production
395 '//{s}.{base}.maps.cit.api.here.com/maptile/2.1/' +
396 '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' +
397 'app_id={app_id}&app_code={app_code}&lg={language}',
400 'Map © 1987-2014 <a href="http://developer.here.com">HERE</a>',
403 'app_id': '<insert your app_id here>',
404 'app_code': '<insert your app_code here>',
406 variant
: 'normal.day',
414 normalDay
: 'normal.day',
415 normalDayCustom
: 'normal.day.custom',
416 normalDayGrey
: 'normal.day.grey',
417 normalDayMobile
: 'normal.day.mobile',
418 normalDayGreyMobile
: 'normal.day.grey.mobile',
419 normalDayTransit
: 'normal.day.transit',
420 normalDayTransitMobile
: 'normal.day.transit.mobile',
421 normalNight
: 'normal.night',
422 normalNightMobile
: 'normal.night.mobile',
423 normalNightGrey
: 'normal.night.grey',
424 normalNightGreyMobile
: 'normal.night.grey.mobile',
443 carnavDayGrey
: 'carnav.day.grey',
447 variant
: 'hybrid.day'
453 variant
: 'hybrid.day.mobile'
456 pedestrianDay
: 'pedestrian.day',
457 pedestrianNight
: 'pedestrian.night',
461 variant
: 'satellite.day'
467 variant
: 'terrain.day'
473 variant
: 'terrain.day.mobile'
479 url
: 'http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg',
484 bounds
: [[47.204642, 15.996093], [49.830896, 22.576904]],
486 '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 <a href="http://freemap.sk">Freemap.sk</a>'
490 url
: 'http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png',
493 '{attribution.OpenStreetMap} & USGS'
497 url
: 'http://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}.png',
499 attribution
: '{attribution.OpenStreetMap} © <a href="http://cartodb.com/attributions">CartoDB</a>',
505 Positron
: 'light_all',
506 PositronNoLabels
: 'light_nolabels',
507 PositronOnlyLabels
: 'light_only_labels',
508 DarkMatter
: 'dark_all',
509 DarkMatterNoLabels
: 'dark_nolabels',
510 DarkMatterOnlyLabels
: 'dark_only_labels'
514 url
: 'http://{s}.tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png',
517 attribution
: '{attribution.OpenStreetMap}',
525 variant
: 'hillshading'
531 url
: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}',
534 attribution
: 'Datenquelle: <a href="www.basemap.at">basemap.at</a>',
535 subdomains
: ['', '1', '2', '3', '4'],
537 bounds
: [[46.358770, 8.782379], [49.037872, 17.189532]],
538 variant
: 'geolandbasemap'
541 basemap
: 'geolandbasemap',
543 overlay
: 'bmapoverlay',
546 variant
: 'bmaphidpi',
552 variant
: 'bmaporthofoto30cm',
559 url
: '//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}',
562 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' +
563 '(<a href="https://earthdata.nasa.gov">ESDIS</a>) with funding provided by NASA/HQ.',
564 bounds
: [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]],
569 tilematrixset
: 'GoogleMapsCompatible_Level'
572 ModisTerraTrueColorCR
: 'MODIS_Terra_CorrectedReflectance_TrueColor',
573 ModisTerraBands367CR
: 'MODIS_Terra_CorrectedReflectance_Bands367',
574 ViirsEarthAtNight2012
: {
576 variant
: 'VIIRS_CityLights_2012',
582 variant
: 'MODIS_Terra_Land_Surface_Temp_Day',
588 ModisTerraSnowCover
: {
590 variant
: 'MODIS_Terra_Snow_Cover',
598 variant
: 'MODIS_Terra_Aerosol',
604 ModisTerraChlorophyll
: {
606 variant
: 'MODIS_Terra_Chlorophyll_A',
615 // NLS maps are copyright National library of Scotland.
616 // http://maps.nls.uk/projects/api/index.html
617 // Please contact NLS for anything other than non-commercial low volume usage
619 // Map sources: Ordnance Survey 1:1m to 1:63K, 1920s-1940s
621 // z10-11 - quarter inch (1:253440)
622 // z12-18 - one inch (1:63360)
623 url
: '//nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg',
625 attribution
: '<a href="http://geo.nls.uk/maps/">National Library of Scotland Historic Maps</a>',
626 bounds
: [[49.6, -12], [61.7, 3]],
634 L
.tileLayer
.provider = function (provider
, options
) {
635 return new L
.TileLayer
.Provider(provider
, options
);