Last active
February 8, 2019 16:45
-
-
Save ThomasG77/cb12b00df3a5c117dbe5 to your computer and use it in GitHub Desktop.
Demo WMS 1.1.1 due to question https://groups.google.com/forum/?#!msg/ol3-dev/D-I_zmVZKP8/7r7yiwJeHE4J
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Jsonix WMS</title> | |
<script src="https://cdn.jsdelivr.net/gh/highsource/jsonix@master/dist/Jsonix-min.js"></script> | |
<script src="https://cdn.jsdelivr.net/gh/highsource/w3c-schemas@master/scripts/lib/XLink_1_0.js"></script> | |
<script src="https://cdn.jsdelivr.net/gh/highsource/ogc-schemas@master/scripts/lib/WMS_1_1_1.js"></script> | |
</head> | |
<body> | |
<script> | |
// Trick for demo to manage Cors | |
(function() { | |
var cors_api_host = 'cors-anywhere.herokuapp.com'; | |
var cors_api_url = 'https://' + cors_api_host + '/'; | |
var slice = [].slice; | |
var origin = window.location.protocol + '//' + window.location.host; | |
var open = XMLHttpRequest.prototype.open; | |
XMLHttpRequest.prototype.open = function() { | |
var args = slice.call(arguments); | |
var targetOrigin = /^https?:\/\/([^\/]+)/i.exec(args[1]); | |
if (targetOrigin && targetOrigin[0].toLowerCase() !== origin && | |
targetOrigin[1] !== cors_api_host) { | |
args[1] = cors_api_url + args[1]; | |
} | |
return open.apply(this, args); | |
}; | |
})(); | |
var context = new Jsonix.Context([XLink_1_0, WMS_1_1_1], { | |
// Not required but recommended | |
namespacePrefixes: { | |
'http://www.w3.org/1999/xlink': 'xlink', | |
'http://www.opengis.net/wms': 'wms' | |
} | |
}); | |
var unmarshaller = context.createUnmarshaller(); | |
unmarshaller.unmarshalURL('http://demo.mapserver.org/cgi-bin/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities', function(result) { | |
console.log(JSON.stringify(result, null, 2)); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment