add a REST example in wmts-capabilities

This commit is contained in:
Stéphane Brunner
2012-03-03 17:54:42 +01:00
committed by Stéphane Brunner
parent c4a087d4dd
commit da67953c61
2 changed files with 54 additions and 12 deletions
+10 -4
View File
@@ -20,15 +20,21 @@
<h1 id="title">Web Map Tile Service (WMTS) Capabilities Parsing</h1> <h1 id="title">Web Map Tile Service (WMTS) Capabilities Parsing</h1>
<div id="tags"> <div id="tags">
wmts, capabilities, getcapabilities wmts, capabilities, getcapabilities
</div> </div>
<p id="shortdesc"> <p id="shortdesc">
The WMTS Capabilities format allows for parsing of capabilities The WMTS Capabilities format allows for parsing of capabilities
documents from OGC Web Map Tile Service (WMTS) version 1.0.0 documents from OGC Web Map Tile Service (WMTS) version 1.0.0
implementations. implementations.
</p> </p>
<p>KVP version.</p>
<div id="map" class="smallmap"></div> <div id="map" class="smallmap"></div>
<p>REST version.</p>
<div id="map2" class="smallmap" style="height: 440px; "></div>
<div id="docs"> <div id="docs">
<p> <p>
This example creates an OpenLayers.Layer.WMTS layer to based This example creates an OpenLayers.Layer.WMTS layer to based
+44 -8
View File
@@ -1,15 +1,20 @@
OpenLayers.ProxyHost = "/proxy/?url="; OpenLayers.ProxyHost = "/proxy/?url=";
var map, format; var map, format;
var map2, format2;
function init() { function init() {
/*
* KVP version
*/
format = new OpenLayers.Format.WMTSCapabilities({ format = new OpenLayers.Format.WMTSCapabilities({
/** /**
* This particular service is not in compliance with the WMTS spec and * This particular service is not in compliance with the WMTS spec and
* is providing coordinates in y, x order regardless of the CRS. To * is providing coordinates in y, x order regardless of the CRS. To
* work around this, we can provide the format a table of CRS URN that * work around this, we can provide the format a table of CRS URN that
* should be considered y, x order. These will extend the defaults on * should be considered y, x order. These will extend the defaults on
* the format. * the format.
*/ */
yx: { yx: {
@@ -38,22 +43,53 @@ function init() {
isBaseLayer: false isBaseLayer: false
}); });
map.addLayer(layer); map.addLayer(layer);
}, },
failure: function() { failure: function() {
alert("Trouble getting capabilities doc"); alert("Trouble getting capabilities doc");
OpenLayers.Console.error.apply(OpenLayers.Console, arguments); OpenLayers.Console.error.apply(OpenLayers.Console, arguments);
} }
}); });
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: "EPSG:900913" projection: "EPSG:900913"
}); });
var osm = new OpenLayers.Layer.OSM(); var osm = new OpenLayers.Layer.OSM();
map.addLayer(osm); map.addLayer(osm);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13); map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13);
/*
* REST version
*/
format2 = new OpenLayers.Format.WMTSCapabilities();
OpenLayers.Request.GET({
url: "http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml",
success: function(request) {
var doc = request.responseXML;
if (!doc || !doc.documentElement) {
doc = request.responseText;
}
var capabilities = format2.read(doc);
var layer = format2.createLayer(capabilities, {
layer: "ch.are.gemeindetyp-1990-9klassen",
// not avalable in the WMTS Capabilities in native projection
maxExtent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
});
map2.addLayer(layer);
map2.setCenter(new OpenLayers.LonLat(540000, 160000), 17);
},
failure: function() {
alert("Trouble getting capabilities doc");
OpenLayers.Console.error.apply(OpenLayers.Console, arguments);
}
});
map2 = new OpenLayers.Map({
div: "map2"
});
} }