Advertisement
Guest User

WMTS and Openlayers

a guest
Jun 19th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  6.     <meta name="apple-mobile-web-app-capable" content="yes">
  7.     <script src="http://openlayers.org/api/2.12-rc7/OpenLayers.js"></script>
  8.     <link rel="stylesheet" href="http://dev.openlayers.org/releases/OpenLayers-2.11/examples/style.css" type="text/css">
  9.     <script>
  10.  
  11. var map;
  12.  
  13. function init() {  
  14.   var epsg = "EPSG:23029";
  15.   var bounds = new OpenLayers.Bounds(460000,4625000,690000,4855000);
  16.  
  17.   var options = {
  18.     projection: new OpenLayers.Projection(epsg),
  19.     displayProjection: new OpenLayers.Projection(epsg),
  20.     units: "m",
  21.     tileSize: new OpenLayers.Size(256,256),
  22.     maxExtent: bounds
  23. };
  24.  map = new OpenLayers.Map("map",options);
  25.  
  26. //mymatrixids29: extraido del capabilities del servicio "mtn25ign@23029"
  27. var mymatrixids29 =[{"supportedCRS":"EPSG:23029","identifier":"5","scaleDenominator":8719308.03571429,"topLeftCorner":{"lon":0,"lat":5000000},"tileWidth":256,"tileHeight":256,"matrixWidth":3,"matrixHeight":2},{"supportedCRS":"EPSG:23029","identifier":"6","scaleDenominator":4359654.01785714,"topLeftCorner":{"lon":312500,"lat":5000000},"tileWidth":256,"tileHeight":256,"matrixWidth":5,"matrixHeight":4},{"supportedCRS":"EPSG:23029","identifier":"7","scaleDenominator":2179827.00892857,"topLeftCorner":{"lon":312500,"lat":5000000},"tileWidth":256,"tileHeight":256,"matrixWidth":9,"matrixHeight":7},{"supportedCRS":"EPSG:23029","identifier":"8","scaleDenominator":1089913.50446429,"topLeftCorner":{"lon":390625,"lat":5000000},"tileWidth":256,"tileHeight":256,"matrixWidth":17,"matrixHeight":13},{"supportedCRS":"EPSG:23029","identifier":"9","scaleDenominator":544956.752232143,"topLeftCorner":{"lon":429687.5,"lat":4960937.5},"tileWidth":256,"tileHeight":256,"matrixWidth":33,"matrixHeight":25},{"supportedCRS":"EPSG:23029","identifier":"10","scaleDenominator":272478.376116071,"topLeftCorner":{"lon":449218.75,"lat":4941406.25},"tileWidth":256,"tileHeight":256,"matrixWidth":66,"matrixHeight":48},{"supportedCRS":"EPSG:23029","identifier":"11","scaleDenominator":136239.188058036,"topLeftCorner":{"lon":449218.75,"lat":4941406.25},"tileWidth":256,"tileHeight":256,"matrixWidth":131,"matrixHeight":95},{"supportedCRS":"EPSG:23029","identifier":"12","scaleDenominator":68119.5940290179,"topLeftCorner":{"lon":454101.5625,"lat":4941406.25},"tileWidth":256,"tileHeight":256,"matrixWidth":261,"matrixHeight":189},{"supportedCRS":"EPSG:23029","identifier":"13","scaleDenominator":34059.7970145089,"topLeftCorner":{"lon":454101.5625,"lat":4941406.25},"tileWidth":256,"tileHeight":256,"matrixWidth":521,"matrixHeight":377},{"supportedCRS":"EPSG:23029","identifier":"14","scaleDenominator":17029.8985072545,"topLeftCorner":{"lon":454101.5625,"lat":4940185.546875},"tileWidth":256,"tileHeight":256,"matrixWidth":1041,"matrixHeight":753},{"supportedCRS":"EPSG:23029","identifier":"15","scaleDenominator":8514.94925362723,"topLeftCorner":{"lon":454711.9140625,"lat":4939575.1953125},"tileWidth":256,"tileHeight":256,"matrixWidth":2080,"matrixHeight":1505},{"supportedCRS":"EPSG:23029","identifier":"16","scaleDenominator":4257.47462681362,"topLeftCorner":{"lon":454711.9140625,"lat":4939270.0195313},"tileWidth":256,"tileHeight":256,"matrixWidth":4160,"matrixHeight":3009},{"supportedCRS":"EPSG:23029","identifier":"17","scaleDenominator":2128.73731340681,"topLeftCorner":{"lon":454711.9140625,"lat":4939270.0195313},"tileWidth":256,"tileHeight":256,"matrixWidth":8319,"matrixHeight":6017},{"supportedCRS":"EPSG:23029","identifier":"18","scaleDenominator":1064.3686567034,"topLeftCorner":{"lon":454788.20800781,"lat":4939193.7255859},"tileWidth":256,"tileHeight":256,"matrixWidth":16636,"matrixHeight":12033}];
  28.     var iberpixLayer = new OpenLayers.Layer.WMTS({
  29.         name: "Iberpix",        
  30.         url: "http://www.ign.es/wmts/ot/wmtsservice.aspx",
  31.         layer: "mtn25ign",
  32.         matrixSet: "mtn25ign@23029",
  33.         matrixIds: mymatrixids29,
  34.         format: "image/jpeg",
  35.         style: "default",
  36.         isBaseLayer: true
  37.     });
  38. map.addLayer(iberpixLayer);
  39.  
  40. var topoLayer = new OpenLayers.Layer.WMS("IGN-Base",
  41.                          "http://www.ign.es/wms-inspire/ign-base", {
  42.                          layers: "IGNBaseTodo"
  43.                          }, {
  44.                          isBaseLayer: true,
  45.                          buffer: 0,
  46.                          transitionEffect: 'resize',
  47.                          visibility: false
  48.                          }
  49.                         );
  50.     map.addLayer(topoLayer);
  51.     map.addControl(new OpenLayers.Control.LayerSwitcher());
  52.     map.zoomToExtent(bounds, true);
  53. }
  54.  
  55. </script>
  56. </head>
  57.     <body onload="init();">
  58.         <h1 id="title">Prueba de WMTS del IGN en Galicia</h1>
  59.         <p>
  60.             IGN wmts en galicia
  61.         </p>
  62.        
  63.         <div id="map" class="smallmap"></div>
  64.         <p>Al cambiar de capa en base, se puede ver el desplazamiento de la capa WMTS</p>
  65.     </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement