Skip to content

Commit 8a9d85a

Browse files
Add logging of pixel value to console on mouse move
1 parent a9e9405 commit 8a9d85a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ const layers = {
8686
waterbalance_cumulated: "Kumulierte klimatische Wasserbilanz während der Vegetationsperiode bestehend aus den Komponenten Niederschlag, Beregnung und Verdunstung in Liter je Quadratmeter [mm]."
8787
}
8888

89+
var layerForDataExtraction;
90+
8991
for (var name in layers) {
9092
console.log(name, layers[name]);
9193
let source = new GeoTIFF({
@@ -121,6 +123,9 @@ for (var name in layers) {
121123
});
122124
map.addLayer(layer);
123125
console.log(layer);
126+
if (name == 'precipitation') {
127+
layerForDataExtraction = layer;
128+
}
124129
}
125130

126131
addMeasureTool(map);
@@ -130,3 +135,9 @@ const layerSwitcher = new LayerSwitcher({
130135
groupSelectStyle: 'group'
131136
});
132137
map.addControl(layerSwitcher);
138+
139+
function displayPixelValue(event) {
140+
const data = layerForDataExtraction.getData(event.pixel);
141+
console.log(data);
142+
}
143+
map.on(['pointermove', 'click'], displayPixelValue);

0 commit comments

Comments
 (0)