[Wiki] M.Remote.POST
by Francisco
HTML
<script src="http://mapea4-sigc.juntadeandalucia.es/js/mapea.ol.min.js"></script>
<link rel="stylesheet" href="http://mapea4-sigc.juntadeandalucia.es/assets/css/mapea.ol.min.css">
<script src="http://mapea4-sigc.juntadeandalucia.es/js/configuration.js"></script>
<div id="map"></div>
CSS
html,
body,
#map {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
//Creamos el mapa
var mapajs = M.map({
container: "map",
wmcfiles: ["cdau"]
});
mapajs.getMapImpl().on('click', function(e) {
let url = 'http://www.ieca.junta-andalucia.es/geoserver-ieca/topp/wfs?';
console.log('Proxy POST...');
let request = '<wfs:GetFeature service="WFS" version="1.0.0"' +
' outputFormat="CSV"' +
' xmlns:topp="http://www.openplans.org/topp"' +
' xmlns:wfs="http://www.opengis.net/wfs"' +
' xmlns:ogc="http://www.opengis.net/ogc"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xsi:schemaLocation="http://www.opengis.net/wfs' +
' http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">' +
'<wfs:Query typeName="topp:andprov">' +
'</wfs:Query>' +
'</wfs:GetFeature>';
M.remote.post(url, request).then(res => console.log(JSON.parse(res.text)))
});