-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapa_dustee3.htm
58 lines (48 loc) · 2.29 KB
/
mapa_dustee3.htm
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
<html>
<head>
<title>ScalarField / Geotiff</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<link rel="stylesheet" href="examples.css" />
</head>
<body>
<h1 class="title mapTitle">ScalarField GeoTIFF</h1>
<div id="map"></div>
<!-- CDN -->
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/leaflet.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/geotiff.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.0/chroma.min.js"></script>
<!-- Plugin -->
<script src="https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/dist/leaflet.canvaslayer.field.js"></script>
<script>
let map = L.map('map');
/* Dark basemap */
let url = 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}.png';
L.tileLayer(url, {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://carto.com/attributions">CARTO</a>',
subdomains: 'abcd'
}).addTo(map);
/* chroma.scale('YlGnBu'); chroma.scale('Spectral'); domain([0,0.6]) or -1,1 */
d3.request("pokus.tif").responseType('arraybuffer').get(
function (error, tiffData) {
let hodnota = L.ScalarField.fromGeoTIFF(tiffData.response);
let layer = L.canvasLayer.scalarField(hodnota, {
color: chroma.scale('YlGnBu').domain(hodnota.range),
inFilter: (v) => v !== 0
}).addTo(map);
layer.on('click', function (e) {
if (e.value !== null) {
let v = e.value.toFixed(2);
let html = (`<span class="popupText">Hodnota ${v} jednotka</span>`);
let popup = L.popup()
.setLatLng(e.latlng)
.setContent(html)
.openOn(map);
}
});
map.fitBounds(layer.getBounds());
});
</script>
</body>
</html>