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:
<SPAN class="keyword token">const</SPAN> variableLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ImageryLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'https://this_is_a_fake_url/ImageServer'</SPAN><SPAN class="punctuation token">,</SPAN>
popupTemplate<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'{Raster.ServicePixelValue} variable count(s) in {Year}'</SPAN>
content<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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:
<SPAN class="keyword token">const</SPAN> variableLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ImageryLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'https://this_is_a_fake_url/ImageServer'</SPAN><SPAN class="punctuation token">,</SPAN>
popupTemplate<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//title: '{Raster.ServicePixelValue} variable count(s) in {Year}'</SPAN>
content<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'{expression/pixelvalue} variable count(s) in {Year}'</SPAN><SPAN class="punctuation token">,</SPAN>
expressionInfos<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">{</SPAN>
name<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'pixelvalue'</SPAN><SPAN class="punctuation token">,</SPAN>
expression<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'Round($Raster.ServicePixelValue, 2)'</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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.