add an example

This commit is contained in:
Bart van den Eijnden
2013-02-07 10:45:35 +01:00
parent 6484760507
commit f16664cb87
3 changed files with 84 additions and 5 deletions

View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
html, body, #map {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#log {
height: 500px;
position: absolute;
top: 130px;
}
#text {
position: absolute;
top: 8px;
right: 8px;
z-index: 20000;
background-color: white;
padding: 0 0.5em 0.5em 0.5em;
border-radius: 4px;
}
@media only screen and (max-width: 600px) {
#text {
display: none;
}
}
</style>
<title>wms capabilities example</title>
</head>
<body>
<div id="log"></div>
<div id="map">
<div id="text">
<h1 id="title">WMS GetCapabilities parsing example</h1>
<div id="shortdesc">Example of parsing a WMS GetCapabilities response.</div>
<div id="docs">
<p>See the
<a href="wms-capabilities.js" target="_blank">wms-capabilities.js source</a>
to see how this is done.</p>
</div>
</div>
</div>
<div id="tags">wms, capabilities, getcapabilities</div>
<script src="loader.js?id=wms-capabilities" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,26 @@
goog.require('goog.debug.Console');
goog.require('goog.debug.DivConsole');
goog.require('goog.debug.Logger');
goog.require('goog.debug.Logger.Level');
goog.require('goog.json.Serializer');
goog.require('goog.net.XhrIo');
goog.require('ol.parser.ogc.WMSCapabilities');
if (goog.DEBUG) {
goog.debug.Console.autoInstall();
goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
logconsole.setCapturing(true);
}
var parser = new ol.parser.ogc.WMSCapabilities(), result;
var url = '../test/spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
result = parser.read(xhr.getResponseXml());
if (goog.DEBUG) {
var output = new goog.json.Serializer().serialize(result);
goog.debug.Logger.getLogger('ol').info(output);
}
});

View File

@@ -34,12 +34,12 @@ ol.ENABLE_WMSCAPS_1_1_1_WMSC = true;
/** /**
* @constructor * @constructor
* @param {Object} formatOptions Options which will be set on this object. * @param {Object=} opt_options Options which will be set on this object.
* @extends {ol.parser.ogc.Versioned} * @extends {ol.parser.ogc.Versioned}
*/ */
ol.parser.ogc.WMSCapabilities = function(formatOptions) { ol.parser.ogc.WMSCapabilities = function(opt_options) {
formatOptions = formatOptions || {}; opt_options = opt_options || {};
formatOptions['defaultVersion'] = '1.1.1'; opt_options['defaultVersion'] = '1.1.1';
this.parsers = {}; this.parsers = {};
if (ol.ENABLE_WMSCAPS_1_1_0) { if (ol.ENABLE_WMSCAPS_1_1_0) {
this.parsers['v1_1_0'] = ol.parser.ogc.WMSCapabilities_v1_1_0; this.parsers['v1_1_0'] = ol.parser.ogc.WMSCapabilities_v1_1_0;
@@ -53,6 +53,6 @@ ol.parser.ogc.WMSCapabilities = function(formatOptions) {
if (ol.ENABLE_WMSCAPS_1_3_0) { if (ol.ENABLE_WMSCAPS_1_3_0) {
this.parsers['v1_3_0'] = ol.parser.ogc.WMSCapabilities_v1_3_0; this.parsers['v1_3_0'] = ol.parser.ogc.WMSCapabilities_v1_3_0;
} }
goog.base(this, formatOptions); goog.base(this, opt_options);
}; };
goog.inherits(ol.parser.ogc.WMSCapabilities, ol.parser.ogc.Versioned); goog.inherits(ol.parser.ogc.WMSCapabilities, ol.parser.ogc.Versioned);