Hello,
I have an 32 bit Float single-band ImageryLayer with a popupTemplate assigned.
The popup shows the raster service pixel value with the following code:
const variableLayer = new ImageryLayer({
url: 'https://this_is_a_fake_url/ImageServer',
popupTemplate: {
title: '{Raster.ServicePixelValue} variable count(s) in {Year}'
content: [],
},
});
Is there a way to round the service pixel value which is displayed in the popup? Note: I do not want to round the raster data pixels themselves.
I've tried something like this:
const variableLayer = new ImageryLayer({
url: 'https://this_is_a_fake_url/ImageServer',
popupTemplate: {
//title: '{Raster.ServicePixelValue} variable count(s) in {Year}'
content: '{expression/pixelvalue} variable count(s) in {Year}',
expressionInfos: [{
name: 'pixelvalue',
expression: 'Round($Raster.ServicePixelValue, 2)'
}]
},
});
Any combination of experimenting that I've tried has resulted in either undefined or null in the place where the pixel value should be displayed in the popup.
Any help is massively appreciated! Thank you for reading.
Solved! Go to Solution.
I've found the answer on the updated page for popupTemplate
let popupTemplate = {
title: '',
fieldInfos: [{
fieldName: 'Raster.ItemPixelValue',
format: {
places: 0, // precision
digitSeparator: true // thousands comma separator
}
}]
};
I've found the answer on the updated page for popupTemplate
let popupTemplate = {
title: '',
fieldInfos: [{
fieldName: 'Raster.ItemPixelValue',
format: {
places: 0, // precision
digitSeparator: true // thousands comma separator
}
}]
};