Using HTTP POST for WMS service??
See original GitHub issueHello!
We’ve been using leaflet version 0.7.7, and the WMS service we use doesn’t use the traditional HTTP Get method but rather uses POST. We had this shim to help with this
var TileLayerSoils = L.TileLayer.WMS.extend({
options: {
sld_body: ''
},
createTile: function _loadTile(tile, tilePoint) {
tile._layer = this;
tile.onload = this._tileOnLoad;
tile.onerror = this._tileOnError;
this._adjustTilePoint(tilePoint);
const xhr = new XMLHttpRequest();
const splitUrl = this.getTileUrl(tilePoint).split('?');
xhr.open('POST', splitUrl[0]);
xhr.responseType = 'blob';
xhr.onload = function xhrLoadCallback() { tile.src = window.URL.createObjectURL(this.response); };
xhr.send(splitUrl[1]);
this.fire('tileloadstart', {
tile: tile,
url: tile.src
});
},
getTileUrl: function getTileUrl(tilePoint) {
const map = this._map;
const tileSize = this.options.tileSize;
const nwPoint = tilePoint.multiplyBy(tileSize);
const sePoint = nwPoint.add([tileSize, tileSize]);
const nw = this._crs.project(map.unproject(nwPoint, tilePoint.z));
const se = this._crs.project(map.unproject(sePoint, tilePoint.z));
const bbox = this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?
[se.y, nw.x, nw.y, se.x].join(',') :
[nw.x, se.y, se.x, nw.y].join(',');
let url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)});
const params = [];
for (const key in this.wmsParams) {
if (Object.prototype.hasOwnProperty.call(this.wmsParams, key)) {
params.push(key.toUpperCase() + '=' + this.wmsParams[key]);
}
}
url = url + ((!url || url.indexOf('?') === -1) ? '?' : '&') + params.join('&');
return url + '&BBOX=' + bbox + '&SLD_BODY=' + this.options.sld_body;
},
});
Now after updating to the latest the loadtile method has been deprecated and I can’t seem to figure out what method to attach this shim to. After I successfully add a way to use HTTP Post shim for a WMS service ill submit a pr as I think it can be useful.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Mapserver WMS HTTP POST requests - GIS Stack Exchange
The ability for MapServer to be able to receive Post requests with XML-encoded information sent in the body of the request has been...
Read more >Communicating with a WMS service in a web browser ...
You can use URL parameters to communicate with a WMS service in a web browser. WMS request and response. The online resource of...
Read more >WMS Web Service APIs - Oracle Help Center
Oracle WMS Cloud provides REST based Web Service APIs to perform various ... You can use the Chrome plugin Postman to try out...
Read more >Part 2: XML for Requests using HTTP Post - OGC Portal
The OGC Web Map Service (WMS) implementation specification version 1.1.0 defines keyword/value encodings for operation requests using HTTP GET. This document.
Read more >GetCapabilities - Esri Support
The GetCapabilities request provides the following information about a WMS service: All interfaces a WMS service can support; Image formats it can serve ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://anitagraser.com/2010/06/09/getmap-from-geoserver-using-http-post/
Usually, I use CQL filter statements to dynamically filter features in a Geoserver WMS. These CQL filters can be added easily to the URL and Geoserver responds accordingly. There’s just one problem: There is a size limit for URLs and (very!) long filter statements won’t fit in. This makes it necessary to switch from HTTP GET to POST
@kunalbhatt Could you please suggest a plugin to implement POST, the idea is to pass the tilelayer options to the body of the request, instead of using the leaflet default tileLayer method that uses query params