1 | goog.require('ol.Map');
|
2 | goog.require('ol.View');
|
3 | goog.require('ol.extent');
|
4 | goog.require('ol.layer.Tile');
|
5 | goog.require('ol.proj');
|
6 | goog.require('ol.source.OSM');
|
7 | goog.require('ol.source.WMTS');
|
8 | goog.require('ol.tilegrid.WMTS');
|
9 |
|
10 |
|
11 |
|
12 | var projection = ol.proj.get('EPSG:3857');
|
13 | var tileSizePixels = 256;
|
14 | var tileSizeMtrs = ol.extent.getWidth(projection.getExtent()) / tileSizePixels;
|
15 | var matrixIds = [];
|
16 | var resolutions = [];
|
17 | for (var i = 0; i <= 14; i++) {
|
18 | matrixIds[i] = i;
|
19 | resolutions[i] = tileSizeMtrs / Math.pow(2, i);
|
20 | }
|
21 | var tileGrid = new ol.tilegrid.WMTS({
|
22 | origin: ol.extent.getTopLeft(projection.getExtent()),
|
23 | resolutions: resolutions,
|
24 | matrixIds: matrixIds
|
25 | });
|
26 |
|
27 | var scalgoToken = 'CC5BF28A7D96B320C7DFBFD1236B5BEB';
|
28 |
|
29 | var wmtsSource = new ol.source.WMTS({
|
30 | url: 'http://ts2.scalgo.com/olpatch/wmts?token=' + scalgoToken,
|
31 | layer: 'SRTM_4_1:SRTM_4_1_flooded_sealevels',
|
32 | format: 'image/png',
|
33 | matrixSet: 'EPSG:3857',
|
34 | attributions: [
|
35 | '<a href="http://scalgo.com">SCALGO</a>',
|
36 | '<a href="http://www.cgiar-csi.org/data/' +
|
37 | 'srtm-90m-digital-elevation-database-v4-1">CGIAR-CSI SRTM</a>'
|
38 | ],
|
39 | tileGrid: tileGrid,
|
40 | style: 'default',
|
41 | dimensions: {
|
42 | 'threshold': 100
|
43 | }
|
44 | });
|
45 |
|
46 | var map = new ol.Map({
|
47 | target: 'map',
|
48 | view: new ol.View({
|
49 | projection: projection,
|
50 | center: [-9871995, 3566245],
|
51 | zoom: 6
|
52 | }),
|
53 | layers: [
|
54 | new ol.layer.Tile({
|
55 | source: new ol.source.OSM()
|
56 | }),
|
57 | new ol.layer.Tile({
|
58 | opacity: 0.5,
|
59 | source: wmtsSource
|
60 | })
|
61 | ]
|
62 | });
|
63 |
|
64 | var updateSourceDimension = function(source, sliderVal) {
|
65 | source.updateDimensions({'threshold': sliderVal});
|
66 | document.getElementById('theinfo').innerHTML = sliderVal + ' meters';
|
67 | };
|
68 |
|
69 | updateSourceDimension(wmtsSource, 10);
|
70 |
|
71 | document.getElementById('slider').addEventListener('input', function() {
|
72 | updateSourceDimension(wmtsSource, this.value);
|
73 | });
|