diff --git a/examples/wmts-capabilities.html b/examples/wmts-capabilities.html new file mode 100644 index 0000000000..b3a210b6cf --- /dev/null +++ b/examples/wmts-capabilities.html @@ -0,0 +1,38 @@ + + + + OpenLayers WMTS Capabilities Example + + + + + + + + +

Web Map Tile Service (WMTS) Capabilities Parsing

+ +

+ The WMTS Capabilities format allows for parsing of capabilities + documents from OGC Web Map Tile Service (WMTS) version 1.0.0 + implementations. +

+ +
+ +
+

+ This example creates an OpenLayers.Layer.WMTS layer to based + on the results of parsing a capabilities doc with the + OpenLayers.Format.WMTSCapabilities parser. +

+ See the + wmts-capabilities.js source to see how this is done. +

+
+ + diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js new file mode 100644 index 0000000000..9ed04ec364 --- /dev/null +++ b/examples/wmts-capabilities.js @@ -0,0 +1,88 @@ +OpenLayers.ProxyHost = "/proxy/?url="; + +var map, format; + +function init() { + + format = new OpenLayers.Format.WMTSCapabilities(); + OpenLayers.Request.GET({ + url: "http://v2.suite.opengeo.org/geoserver/gwc/service/wmts", + params: { + SERVICE: "WMTS", + VERSION: "1.0.0", + REQUEST: "GetCapabilities" + }, + success: function(request) { + var doc = request.responseXML; + if (!doc || !doc.documentElement) { + doc = request.responseText; + } + var capabilities = format.read(doc); + var layer = createLayer(capabilities, { + layer: "medford:buildings", + matrixSet: "EPSG:900913", + format: "image/png", + opacity: 0.7, + isBaseLayer: false + }); + map.addLayer(layer); + }, + failure: function() { + alert("Trouble getting capabilities doc"); + OpenLayers.Console.error.apply(OpenLayers.Console, arguments); + } + }) + + map = new OpenLayers.Map({ + div: "map", + projection: "EPSG:900913", + units: "m", + maxExtent: new OpenLayers.Bounds( + -20037508.34, -20037508.34, 20037508.34, 20037508.34 + ), + maxResolution: 156543.0339 + }); + + var osm = new OpenLayers.Layer.OSM(); + + map.addLayer(osm); + map.addControl(new OpenLayers.Control.LayerSwitcher()); + map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13); + +} + +function createLayer(capabilities, config) { + + var contents = capabilities.contents; + var matrixSet = contents.tileMatrixSets[config.matrixSet]; + + // find the layer definition with the given identifier + var layers = contents.layers; + var layer; + for (var i=0, ii=layers.length; i