-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
102 lines (83 loc) · 3.77 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<title>Leaflet.TileFilter Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="node_modules/leaflet/dist/leaflet.js" type="text/javascript" charset="utf-8"></script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/image-sequencer/dist/image-sequencer.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="node_modules/leaflet/dist/leaflet.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="dist/leaflet.tile-filter.js"></script>
</head>
<body style="margin:0;">
<div id="map" style="width:100%; height:100%; position:absolute; top:0; z-index:1;"></div>
<script>
var map, tileLayer;
(function(){
// based heavily on Apache licensed example at:
// https://github.com/nasa-gibs/gibs-web-examples/blob/master/examples/leaflet/webmercator-epsg3857.js
// basic Leaflet map setup
map = L.map('map', {
center: [28.84, -113.3],
zoom: 12,
// Values are x and y here instead of lat and long elsewhere.
maxBounds: [
[-120, -220],
[120, 220]
]
});
var template =
'https://gibs-{s}.earthdata.nasa.gov/wmts/epsg3857/best/' +
'{layer}/default/{time}/{tileMatrixSet}/{z}/{y}/{x}.jpg';
tileLayer = L.tileLayer(template, {
// layer: 'MODIS_Terra_CorrectedReflectance_TrueColor', // not anymore!
layer: 'MODIS_Terra_CorrectedReflectance_Bands721',
tileMatrixSet: 'GoogleMapsCompatible_Level9',
maxZoom: 9,
time: '2013-11-04',
tileSize: 256,
subdomains: 'abc',
noWrap: true,
continuousWorld: true,
// Prevent Leaflet from retrieving non-existent tiles on the
// borders.
bounds: [
[-85.0511287776, -179.999999975],
[85.0511287776, 179.999999975]
],
attribution:
'<a href="https://wiki.earthdata.nasa.gov/display/GIBS">' +
'NASA EOSDIS GIBS</a> ' +
'<a href="https://github.com/nasa-gibs/web-examples/blob/master/examples/leaflet/webmercator-epsg3857.js">' +
'View Source' +
'</a>'
});
map.addLayer(tileLayer);
/*
* Workaround for 1px lines appearing in some browsers due to fractional transforms
* and resulting anti-aliasing.
* https://github.com/Leaflet/Leaflet/issues/3575
*/
var originalInitTile = L.GridLayer.prototype._initTile;
L.GridLayer.include({
_initTile: function (tile) {
originalInitTile.call(this, tile);
var tileSize = this.getTileSize();
tile.style.width = tileSize.x + 1 + 'px';
tile.style.height = tileSize.y + 1 + 'px';
}
});
// apply NDVI equation to the layer
tileLayer.filter('colormap'); // run NDVI and apply colormap
tileLayer.addTo(map);
})();
</script>
<div id="btns" style="position:absolute;bottom:0;width:100%;z-index:99;padding:8px;">
<a class="btn btn-default" href="#" onClick="tileLayer.revert().filter('ndvi');">NDVI</a>
<a class="btn btn-default" href="#" onClick="tileLayer.revert().filter('colormap{colormap:brntogrn}');">Brown to green colormap</a>
<a class="btn btn-default" href="#" onClick="tileLayer.revert().filter(prompt('Enter an Image Sequencer string; https://sequencer.publiclab.org', 'dynamic{red:R*2|green:B|blue:B/2}'));">Enter command</a>
<a class="btn btn-default" href="#" onClick="tileLayer.revert();">Revert</a>
</div>
</html>