Leaflet Custom Headers is an extension to TileLayer that allows you to add custom headers to HTTP requests when loading tiles.
To install the package, run:
npm install leaflet-custom-headersExample of use with Leaflet:
import {Map} from “leaflet”;
import TileLayerHeaders from “leaflet-custom-headers”;
const map = new Map(“map”).setView([51.505, -0.09], 13);
const layerWithHeaders = new TileLayerHeaders(“https://example.com/tiles/{z}/{x}/{y}.png”, {
customHeaders: {
“Authorization": ”Bearer YOUR_ACCESS_TOKEN”
}
});
layerWithHeaders.addTo(map);customHeaders(optional): Object containing the custom headers to be sent in HTTP requests.
Distributed under MIT license.
🌍 Contribute! If you have suggestions or want to improve the plugin, feel free to open an Issue or a Pull Request in the GitHub repository!