Update leaflet providers library.

This commit is contained in:
David Molineus
2015-06-18 16:17:40 +02:00
parent 8d9a6e7544
commit 0ed4efa08b
6 changed files with 245 additions and 65 deletions

View File

@@ -10,6 +10,11 @@ Leaflet-providers [providers](#providers) are refered to with a `provider[.<vari
L.tileLayer.provider('Stamen.Watercolor').addTo(map);
```
## Protocol relativity (`https://`-urls)
Leaflet-providers tries to use `https://` if the page uses `https://` and the provider supports it.
You can force the use of `http://` by passing `force_http: true` in the options argument.
# Providers
Leaflet-providers provides tile layers from different providers, including *OpenStreetMap*, *MapQuestOpen*, *Stamen*, *Esri* and *OpenWeatherMap*. The full listing of free to use layers can be [previewed](http://leaflet-extras.github.io/leaflet-providers/preview/index.html). The page will show you the name to use with `leaflet-providers.js` and the code to use it without dependencies.
@@ -20,43 +25,29 @@ In addition to the providers you are free to use, we support some layers which r
### HERE (formerly Nokia).
In order to use HERE basemaps, you must [register](http://developer.here.com/get-started). With your `app_id` and `app_code` specified in the options. The available layers are:
In order to use HERE layers, you must [register](http://developer.here.com/). Once registered, you can create an `app_id` and `app_code` which you have to pass to `L.tileLayer.provider` in the options:
* HERE.normalDay
* HERE.normalGreyDay
* HERE.satelliteNoLabelsDay
* HERE.satelliteYesLabelsDay
* HERE.terrainDay
For example:
```Javascript
L.tileLayer.provider('HERE.terrainDay', {
app_id: 'insert ID here',
app_code: 'insert ID here'
app_id: '<insert ID here>',
app_code: '<insert ID here>'
}).addTo(map);
```
[Available HERE layers](http://leaflet-extras.github.io/leaflet-providers/preview/#filter=HERE)
### Mapbox
In order to use Mapbox maps, you must [register](https://tiles.mapbox.com/signup). If your user name is `YourName` and your map is called `MyMap` you can add it with
In order to use Mapbox maps, you must [register](https://tiles.mapbox.com/signup). If your user name is `YourName` and your map is called `MyMap` you can add it with:
```JavaScript
L.tileLayer.provider('MapBox.YourName.MyMap');
```
### Esri/ArcGIS
In order to use ArcGIS maps, you must [register](https://developers.arcgis.com/en/sign-up/) and abide by the [terms of service](https://developers.arcgis.com/en/terms/). Available layers are...
In order to use ArcGIS maps, you must [register](https://developers.arcgis.com/en/sign-up/) and abide by the [terms of service](https://developers.arcgis.com/en/terms/). No special syntax is required.
* Esri.WorldStreetMap
* Esri.DeLorme
* Esri.WorldTopoMap
* Esri.WorldImagery
* Esri.WorldTerrain
* Esri.WorldShadedRelief
* Esri.WorldPhysical
* Esri.OceanBasemap
* Esri.NatGeoWorldMap
* Esri.WorldGrayCanvas
[Available Esri layers](http://leaflet-extras.github.io/leaflet-providers/preview/#filter=Esri)
# Attribution

View File

@@ -1,8 +1,11 @@
{
"name": "leaflet-providers",
"version": "1.0.12",
"version": "1.1.0",
"homepage": "https://github.com/leaflet-extras/leaflet-providers",
"description": "An extension to Leaflet that contains configurations for various free tile providers.",
"dependencies": {
"leaflet": "~0.7.3"
},
"main": "leaflet-providers.js",
"keywords": [
"leaflet",

View File

@@ -1,4 +1,12 @@
(function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['leaflet'], factory);
} else {
// Assume leaflet is loaded into global object L already
factory(L);
}
}(this, function (L) {
'use strict';
L.TileLayer.Provider = L.TileLayer.extend({
@@ -41,6 +49,11 @@
provider.url = provider.url(parts.splice(1, parts.length - 1).join('.'));
}
var forceHTTP = window.location.protocol === 'file:' || provider.options.forceHTTP;
if (provider.url.indexOf('//') === 0 && forceHTTP) {
provider.url = 'http:' + provider.url;
}
// replace attribution placeholders with their values from toplevel provider attribution,
// recursively
var attributionReplacer = function (attr) {
@@ -66,21 +79,33 @@
* see http://leafletjs.com/reference.html#tilelayer for options in the options map.
*/
//jshint maxlen:220
L.TileLayer.Provider.providers = {
OpenStreetMap: {
url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: {
maxZoom: 19,
attribution:
'&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
},
variants: {
Mapnik: {},
BlackAndWhite: {
url: 'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png'
url: 'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png',
options: {
maxZoom: 18
}
},
DE: {
url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png'
url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png',
options: {
maxZoom: 18
}
},
France: {
url: 'http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png',
options: {
attribution: '&copy; Openstreetmap France | {attribution.OpenStreetMap}'
}
},
HOT: {
url: 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
@@ -96,8 +121,15 @@
attribution: 'Map data: &copy; <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
}
},
OpenTopoMap: {
url: '//{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
options: {
maxZoom: 16,
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>)'
}
},
Thunderforest: {
url: 'http://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png',
url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png',
options: {
attribution:
'&copy; <a href="http://www.opencyclemap.org">OpenCycleMap</a>, {attribution.OpenStreetMap}',
@@ -105,7 +137,18 @@
},
variants: {
OpenCycleMap: 'cycle',
Transport: 'transport',
Transport: {
options: {
variant: 'transport',
maxZoom: 19
}
},
TransportDark: {
options: {
variant: 'transport-dark',
maxZoom: 19
}
},
Landscape: 'landscape',
Outdoors: 'outdoors'
}
@@ -113,7 +156,6 @@
OpenMapSurfer: {
url: 'http://openmapsurfer.uni-hd.de/tiles/{variant}/x={x}&y={y}&z={z}',
options: {
minZoom: 0,
maxZoom: 20,
variant: 'roads',
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data {attribution.OpenStreetMap}'
@@ -137,20 +179,24 @@
Hydda: {
url: 'http://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png',
options: {
minZoom: 0,
maxZoom: 18,
variant: 'full',
attribution: 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">OpenStreetMap Sweden</a> &mdash; Map data {attribution.OpenStreetMap}'
},
variants: {
Full: 'full',
Base: 'base',
RoadsAndLabels: 'roads_and_labels',
RoadsAndLabels: 'roads_and_labels'
}
},
MapQuestOpen: {
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg',
/* Mapquest does support https, but with a different subdomain:
* https://otile{s}-s.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}
* which makes implementing protocol relativity impossible.
*/
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}',
options: {
type: 'map',
ext: 'jpg',
attribution:
'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
'Map data {attribution.OpenStreetMap}',
@@ -159,18 +205,25 @@
variants: {
OSM: {},
Aerial: {
url: 'http://oatile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',
options: {
type: 'sat',
attribution:
'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency'
}
},
HybridOverlay: {
options: {
type: 'hyb',
ext: 'png',
opacity: 0.9
}
}
}
},
MapBox: {
url: function (id) {
return 'http://{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png';
return '//{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png';
},
options: {
attribution:
@@ -180,7 +233,7 @@
}
},
Stamen: {
url: 'http://{s}.tile.stamen.com/{variant}/{z}/{x}/{y}.png',
url: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.png',
options: {
attribution:
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
@@ -189,7 +242,8 @@
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20,
variant: 'toner'
variant: 'toner',
ext: 'png'
},
variants: {
Toner: 'toner',
@@ -198,31 +252,47 @@
TonerLines: 'toner-lines',
TonerLabels: 'toner-labels',
TonerLite: 'toner-lite',
Terrain: {
options: {
variant: 'terrain',
minZoom: 4,
maxZoom: 18
}
},
TerrainBackground: {
options: {
variant: 'terrain-background',
minZoom: 4,
maxZoom: 18
}
},
Watercolor: {
options: {
variant: 'watercolor',
minZoom: 1,
maxZoom: 16
}
},
Terrain: {
options: {
variant: 'terrain',
minZoom: 4,
maxZoom: 18,
bounds: [[22, -132], [70, -56]]
}
},
TerrainBackground: {
options: {
variant: 'terrain-background',
minZoom: 4,
maxZoom: 18,
bounds: [[22, -132], [70, -56]]
}
},
TopOSMRelief: {
options: {
variant: 'toposm-color-relief',
ext: 'jpg',
bounds: [[22, -132], [51, -56]]
}
},
TopOSMFeatures: {
options: {
variant: 'toposm-features',
bounds: [[22, -132], [51, -56]],
opacity: 0.9
}
}
}
},
Esri: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}',
url: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}',
options: {
variant: 'World_Street_Map',
attribution: 'Tiles &copy; Esri'
@@ -308,6 +378,7 @@
OpenWeatherMap: {
url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png',
options: {
maxZoom: 19,
attribution: 'Map data &copy; <a href="http://openweathermap.org">OpenWeatherMap</a>',
opacity: 0.5
},
@@ -336,7 +407,7 @@
* envirionments.
*/
url:
'http://{s}.{base}.maps.cit.api.here.com/maptile/2.1/' +
'//{s}.{base}.maps.cit.api.here.com/maptile/2.1/' +
'maptile/{mapID}/{variant}/{z}/{x}/{y}/256/png8?' +
'app_id={app_id}&app_code={app_code}',
options: {
@@ -348,7 +419,6 @@
'app_code': '<insert your app_code here>',
base: 'base',
variant: 'normal.day',
minZoom: 0,
maxZoom: 20
},
variants: {
@@ -441,8 +511,7 @@
options: {
attribution: '{attribution.OpenStreetMap} &copy; <a href="http://cartodb.com/attributions">CartoDB</a>',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 18,
maxZoom: 19,
variant: 'light_all'
},
variants: {
@@ -451,10 +520,113 @@
DarkMatter: 'dark_all',
DarkMatterNoLabels: 'dark_nolabels'
}
},
HikeBike: {
url: 'http://{s}.tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png',
options: {
maxZoom: 19,
attribution: '{attribution.OpenStreetMap}',
variant: 'hikebike'
},
variants: {
HikeBike: {},
HillShading: {
options: {
maxZoom: 15,
variant: 'hillshading'
}
}
}
},
BasemapAT: {
url: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}',
options: {
maxZoom: 19,
attribution: 'Datenquelle: <a href="www.basemap.at">basemap.at</a>',
subdomains: ['', '1', '2', '3', '4'],
format: 'png',
bounds: [[46.358770, 8.782379], [49.037872, 17.189532]],
variant: 'geolandbasemap'
},
variants: {
basemap: 'geolandbasemap',
grau: 'bmapgrau',
overlay: 'bmapoverlay',
highdpi: {
options: {
variant: 'bmaphidpi',
format: 'jpeg'
}
},
orthofoto: {
options: {
variant: 'bmaporthofoto30cm',
format: 'jpeg'
}
}
}
},
NASAGIBS: {
url: '//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}',
options: {
attribution:
'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' +
'(<a href="https://earthdata.nasa.gov">ESDIS</a>) with funding provided by NASA/HQ.',
bounds: [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]],
minZoom: 1,
maxZoom: 9,
format: 'jpg',
time: '',
tilematrixset: 'GoogleMapsCompatible_Level'
},
variants: {
ModisTerraTrueColorCR: 'MODIS_Terra_CorrectedReflectance_TrueColor',
ModisTerraBands367CR: 'MODIS_Terra_CorrectedReflectance_Bands367',
ViirsEarthAtNight2012: {
options: {
variant: 'VIIRS_CityLights_2012',
maxZoom: 8
}
},
ModisTerraLSTDay: {
options: {
variant: 'MODIS_Terra_Land_Surface_Temp_Day',
format: 'png',
maxZoom: 7,
opacity: 0.75
}
},
ModisTerraSnowCover: {
options: {
variant: 'MODIS_Terra_Snow_Cover',
format: 'png',
maxZoom: 8,
opacity: 0.75
}
},
ModisTerraAOD: {
options: {
variant: 'MODIS_Terra_Aerosol',
format: 'png',
maxZoom: 6,
opacity: 0.75
}
},
ModisTerraChlorophyll: {
options: {
variant: 'MODIS_Terra_Chlorophyll_A',
format: 'png',
maxZoom: 7,
opacity: 0.75
}
}
}
}
};
L.tileLayer.provider = function (provider, options) {
return new L.TileLayer.Provider(provider, options);
};
}());
return L;
}));

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "leaflet-providers",
"version": "1.0.12",
"version": "1.1.0",
"description": "An extension to Leaflet that contains configurations for various free tile providers.",
"main": "leaflet-providers.js",
"repository": {
@@ -8,7 +8,9 @@
"url": "git://github.com/leaflet-extras/leaflet-providers.git"
},
"scripts": {
"test": "jshint leaflet-providers.js preview/*.js",
"test": "npm run lint && npm run testsuite",
"testsuite": "mocha-phantomjs tests/index.html",
"lint": "eslint --config .eslintrc leaflet-providers.js preview/preview.js preview/shared.js preview/https-support.js tests/test.js",
"min": "uglifyjs leaflet-providers.js -mc -o leaflet-providers.min.js",
"release": "mversion patch -m"
},
@@ -17,8 +19,20 @@
"url": "https://github.com/leaflet-extras/leaflet-providers/issues"
},
"devDependencies": {
"jshint": "~2.1.11",
"chai": "^2.3.0",
"eslint": "^0.15.0",
"mocha": "^2.2.4",
"mocha-phantomjs": "^3.5.3",
"mversion": "^1.3.0",
"uglify-js": "^2.4.15"
"uglify-js": "^2.4.15",
"phantomjs": "^1.9.16"
},
"autoupdate": {
"source": "git",
"target": "git://github.com/leaflet-extras/leaflet-providers.git",
"basePath": "/",
"files": [
"leaflet-providers.js"
]
}
}