Files
openlayers/examples/wmts-layer-from-capabilities.js
Sara Metz 6894bc8444 Add ability to get wmts source from capabilities
Added functionality to create a wmts tilegrid and wmts source from the
capabilities object created from ol.format.WMTSCapabilities.read().
Added tests for these functions and an example.

Also altered the REST url template replacement to be case insensitive
and added tests for this. This is because the spec uses both style
and Style and both of these are used by existing WMTS services.
2015-02-25 09:21:45 +13:00

38 lines
967 B
JavaScript

goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.format.WMTSCapabilities');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.OSM');
goog.require('ol.source.WMTS');
var parser = new ol.format.WMTSCapabilities();
var map;
$.ajax('data/WMTSCapabilities.xml').then(function(response) {
var result = parser.read(response);
var options = ol.source.WMTS.optionsFromCapabilities(result,
{layer: 'layer-7328', matrixSet: 'EPSG:3857'});
var projection = ol.proj.get('EPSG:3857');
var projectionExtent = projection.getExtent();
map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM(),
opacity: 0.7
}),
new ol.layer.Tile({
opacity: 1,
extent: projectionExtent,
source: new ol.source.WMTS(options)
})
],
target: 'map',
view: new ol.View({
center: [19412406.33, -5050500.21],
zoom: 5
})
});
});