Merge pull request #18104 from BendingBender/leaflet-providers

[leaflet-providers] introduce typings
This commit is contained in:
Wesley Wigham
2017-07-17 11:08:06 -07:00
committed by GitHub
4 changed files with 83 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for leaflet-providers 1.1
// Project: https://github.com/leaflet-extras/leaflet-providers#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="leaflet" />
declare namespace L {
namespace TileLayer {
class Provider extends TileLayer {
constructor(provider: string, options?: TileLayerOptions)
}
namespace Provider {
const providers: ProvidersMap;
interface ProvidersMap {
[providerName: string]: ProviderConfig;
}
interface ProviderConfig {
url: string;
options?: TileLayerOptions;
variants?: { [variantName: string]: string | ProviderConfig };
}
}
}
namespace tileLayer {
function provider(provider: string, options?: TileLayerOptions): TileLayer.Provider;
}
}
@@ -0,0 +1,28 @@
const map = L.map('map');
L.tileLayer.provider('Stamen.Watercolor').addTo(map);
L.tileLayer.provider('HERE.terrainDay', {
app_id: '<insert ID here>',
app_code: '<insert ID here>'
}).addTo(map);
new L.TileLayer.Provider('MapBox').addTo(map);
new L.TileLayer.Provider('MapBox', {id: 'ID', accessToken: 'ACCESS_TOKEN'}).addTo(map);
L.TileLayer.Provider.providers['nlmaps'] = {
url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png',
options: {
minZoom: 6,
maxZoom: 19,
bounds: [[50.5, 3.25], [54, 7.6]],
attribution: 'Kaartgegevens &copy; <a href="kadaster.nl">Kadaster</a>'
},
variants: {
standaard: 'brtachtergrondkaart',
pastel: 'brtachtergrondkaartpastel',
grijs: 'brtachtergrondkaartgrijs',
luchtfoto: {
url: 'https://geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/1.0.0/2016_ortho25/EPSG:3857/{z}/{x}/{y}.png',
}
}
};
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"leaflet-providers-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }