stuartmatthews / leaflet-geotiff

Leaflet plugin for displaying geoTIFF raster data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to execute 'addColorStop' on 'CanvasGradient': The provided value (2400) is outside the range (0.0, 1.0)

s9eenk opened this issue · comments

A DOM Exception is raised while rendering the page . Tried to go through the plotty.js file, but don't know where to change the range.

Any help is appreciated . Thanks in advance.

Can you please post some example code? Does this error occur when you are creating a custom color scale?

Here is the reference for addColorStop which is throwing the error.

Hi Mathews,
Exactly , this error occurs when creating a custom color scale. Here , is the code
plotty.js
"res": {
colors: ["#C1CDD7","#63AF61","#B3E287","#F6EB1A","#F1A56A","#F46F16"],
positions: [0,1367,2734,4100,5467]
}
map.html
L.leafletGeotiff(
url='qasz.tif',
options={
band: 1,
displayMin: 0,
displayMax: 6000,
name: 'Sample',
colorScale: 'res'
}
).addTo(mymap);
Note: The pixel values ranges from 0 to 6000.

The positions array needs to be values from 0 to 1, as per the doc, and must have the same number of entries as the colors array, e.g. [0, 0.2, 0.4, 0.6, 0.8, 0.1]

Works !. Great . Thanks Matthews. 👍 I just forgot to put band as 0.