Gathering detailed insights and metrics for leaflet-wms-fn-header
Gathering detailed insights and metrics for leaflet-wms-fn-header
Gathering detailed insights and metrics for leaflet-wms-fn-header
Gathering detailed insights and metrics for leaflet-wms-fn-header
npm install leaflet-wms-fn-header
Typescript
Module System
Node Version
NPM Version
64.5
Supply Chain
98.7
Quality
78.5
Maintenance
100
Vulnerability
98.9
License
JavaScript (67.78%)
HTML (32.22%)
Total Downloads
288
Last Day
1
Last Week
2
Last Month
7
Last Year
288
35 Commits
1 Branches
1 Contributors
Latest Version
1.1.3
Package Id
leaflet-wms-fn-header@1.1.3
Unpacked Size
31.05 kB
Size
6.91 kB
File Count
13
NPM Version
10.2.4
Node Version
20.11.0
Publised On
03 Sept 2024
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
75%
7
Compared to previous month
Last year
0%
288
Compared to previous year
2
1
Custom Headers for Leaflet TileLayer WMS
This lightweight plugin allows you to set custom headers for the WMS interface in Leaflet.
It works seamlessly with both JavaScript and TypeScript, requiring no additional dependencies!
Fork from leaflet-wms-header
Based on https://github.com/Leaflet/Leaflet/issues/2091#issuecomment-302706529.
1$ npm install leaflet leaflet-wms-fn-header --save
1<!-- Assuming your project root is "../" --> 2<script src="../node_modules/leaflet/dist/leaflet.js"></script> 3<script src="../node_modules/leaflet-wms-fn-header/index.js"></script>
1
2// YOUR LEAFLET CODE
3
4var wmsLayer = L.TileLayer.wmsHeader(
5 'https://GEOSERVER_PATH/geoserver/wms?',
6 {
7 layers: 'ne:ne',
8 format: 'image/png',
9 transparent: true,
10 },
11 [
12 { header: 'Authorization', value: 'JWT ' + MYAUTHTOKEN },
13 { header: 'content-type', value: 'text/plain'},
14 ],
15 null, // abort function
16 (err) => console.log (err) // image loading error handling function (optional)
17).addTo(map);
1 2let dynamicToken = 'SOME_TOKEN_1'; 3 4setTimeout(() => { 5 dynamicToken = 'SOME_TOKEN_2'; 6}, 5000) 7 8var wmsLayer = L.TileLayer.wmsHeader( 9 'https://GEOSERVER_PATH/geoserver/wms?', 10 { 11 layers: 'ne:ne', 12 format: 'image/png', 13 transparent: true, 14 }, 15 () => [ 16 { header: 'Authorization', value: 'JWT ' + dynamicToken }, 17 { header: 'content-type', value: 'text/plain'}, 18 ], 19 null 20).addTo(map);
1$ npm install leaflet @types/leaflet leaflet-wms-fn-header --save
1import * as L from 'leaflet';
2import 'leaflet-wms-fn-header';
3
4// YOUR LEAFLET CODE
5
6let wmsLayer: L.TileLayer.WMSHeader = L.TileLayer.wmsHeader(
7 'https://GEOSERVER_PATH/geoserver/wms?',
8 {
9 layers: layers,
10 format: 'image/png',
11 transparent: true,
12 }, [
13 { header: 'Authorization', value: 'JWT ' + MYAUTHTOKEN },
14 { header: 'content-type', value: 'text/plain'},
15 ],
16 null
17).addTo(map);
Abort parameter allow to abort the http request through an Observable. This optimization function might be usefull to stop the http request when it is not necessary anymore, mostly if many requests are pending. An example is provided on /tests/system-tests.html .
See below an example using an Observable as "abort" parameter.
1let tileLayer: L.TileLayer.WMSHeader = L.TileLayer.wmsHeader(
2 'https://GEOSERVER_PATH/geoserver/wms?',
3 {
4 layers: layers,
5 format: 'image/png',
6 transparent: true,
7 }, [
8 { header: 'Authorization', value: 'JWT ' + MYAUTHTOKEN },
9 { header: 'content-type', value: 'text/plain'},
10 ],
11 this.abortWMSObservable$.pipe(take(1))
12);
No vulnerabilities found.
No security vulnerabilities found.