"The explosive growth of the GeoWeb and geographic information has made GIS powerful media for the general public to communicate, but perhaps more importantly, GIS have also become media for constructive dialogs and interactions about social issues." - Sui & Goodchild
var map; var format; function init() { OpenLayers.ImgPath = "http://map.geo.admin.ch/main/wsgi/lib/GeoAdmin.ux/Map/img/"; // Création de la carte map = new OpenLayers.Map({ div: "map", projection: "EPSG:21781", units: "m", controls: [ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.ScaleLine({maxWidth: 120}) ], maxExtent: new OpenLayers.Bounds(0, 0, 1200000, 1200000), resolutions: [650,500,250,100,50,20,10,5,2.5] }); addWMTSLayer(); } function addWMTSLayer() { // Parser spécialisé var format = new OpenLayers.Format.WMTSCapabilities({}); // On va récupérer le fichier "getCapabilities" OpenLayers.Request.GET({ url: "http://api.geo.admin.ch/main/wsgi/doc/data/wmts-getcapabilities.xml?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities", params: { SERVICE: "WMTS", VERSION: "1.0.0", REQUEST: "GetCapabilities" }, success: function(request) { var doc = request.responseXML; if (!doc || !doc.documentElement) { doc = request.responseText; } if (!doc || doc.length <1) { alert("Trouble parsing the getCapabilities document"); return false;} var capabilities = format.read(doc); // Si le parser a pu lire les données, on crée un layer var layer = format.createLayer(capabilities, { layer: "ch.swisstopo.pixelkarte-farbe", matrixSet: "21781", //"Bgdi_lv03", format: "image/jpeg", opacity: 1.0, isBaseLayer: true, requestEncoding: "REST", style: "default" , // must be provided dimensions: ['TIME'], params: {'time': '2009'}, formatSuffix: 'jpeg' }); // Ajout du layer à la map map.addLayer(layer); map.setCenter(new OpenLayers.LonLat(650000, 180000), 2); }, failure: function() { // En cas de problème de la requête XHR alert("Trouble getting capabilities doc"); OpenLayers.Console.error.apply(OpenLayers.Console, arguments); } }); }