Tooltips
One of the best parts of having the original data values instead of images is that it’s possible to query them. Click on this image to see the values for each pixel in the GeoTIFF:
The code is the same as the isobands example. You can find the whole code for the tooltip example here.
- The tooltip div is styled with css
- Note that opacity is set to 0 by default
- A div is added to contain the tooltip information
- An onClick event is added on the canvas element
- The x, y coordinates of the canvas are get with d3.mouse
- projection.invert(screenCoords) convert from x, y in pixels to longitude-latitude
- The inverse GeoTransform is used to get the position in the data Array
- The position is rounded to get the nearest neighbour. An interpolation with the four nearest pixels could be used instead
- The tooltip is set to opacity=1, the position is the one clicked and the text is set to the selected value