Skip to content

Instantly share code, notes, and snippets.

@rrameshkumar76
Last active May 20, 2017 11:09
Show Gist options
  • Save rrameshkumar76/b2596b20142490f902901a581c8807c0 to your computer and use it in GitHub Desktop.
Save rrameshkumar76/b2596b20142490f902901a581c8807c0 to your computer and use it in GitHub Desktop.
Leaflet add headers to wms calls
L.TileLayer.WMS_Headers = L.TileLayer.WMS.extend({
createTile(coords, done) {
const url = this.getTileUrl(coords);
const img = document.createElement('img');
superagent
.get(url)
.set(‘header’, ‘header value’)
.responseType('blob')
.then((response) => {
img.src = URL.createObjectURL(response.body);
done(null, img);
});
return img;
}
});
L.tileLayer.wms_headers = (url, options) => new L.TileLayer.WMS_Headers(url, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment