こんにちは、<\/P>
Webmap でフィーチャ サービスにラベルを付けようとしています。このフィーチャ サービスは 1 メートル区切りのポイント レイヤーです。5 メートルごとの細分化と開始点および終了点にのみラベルを付けたいです。「IIf」と「When」を試しましたが、うまくいきません。<\/P>
ありがとうございます。よろしくお願いします。<\/P>
Bjorn Svensson<\/A><\/P><\/BODY><\/HTML>
What does the data look like?Does the data have attributes with that information? For example, could you just display features where the attributes end in "0m" and "5m"?
If your field "label" is numeric, you could use this:
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>label <SPAN class="operator token">%</SPAN> <SPAN class="number token">5</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> $feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"GEOMETRIA_"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"-"</SPAN> <SPAN class="operator token">+</SPAN> $feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"label"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"m"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="string 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>
This will not label your end-point if the value is not a multiple of 5. You will need to indicate in another field when the value is the end point to do this, since Arcade is not able to read out the maximum value over a series of features.
"Label" field contains measure each 1 meter. But I only want to label 0, numbers ending 0 and 5 and final measure (decimal number). Can I order "label text ending 0, ending 5 and decimal number"? "Label" is string...
So, the "Label" field contains a string and the last value is a decimal number (stored as string). In that case to label the values ending on 0 or 5, you could still use the same sample, however, it is necessary to convert the string to a number using the Number function:
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token function">Number</SPAN><SPAN class="punctuation token">(</SPAN>label<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">%</SPAN> <SPAN class="number token">5</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> $feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"GEOMETRIA_"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"-"</SPAN> <SPAN class="operator token">+</SPAN> $feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"label"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"m"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="string 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>
In case only the last value is a decimal stored as a string (what decimal sign are you using, a dot or a comma?), you could detect that and include that as an additional condition in the expression. To be able to know how to the data is stored, could you include a screenshot of your attribute table showing the values of the Label field?
One of the things you could do is this:
<SPAN class="keyword token">var</SPAN> geom <SPAN class="operator token">=</SPAN> $feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"GEOMETRIA_"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> label <SPAN class="operator token">=</SPAN> $feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"label"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token function">Find</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">","</SPAN><SPAN class="punctuation token">,</SPAN> label<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token function">Number</SPAN><SPAN class="punctuation token">(</SPAN>label<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">%</SPAN> <SPAN class="number token">5</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> geom <SPAN class="operator token">+</SPAN> <SPAN class="string token">"-"</SPAN> <SPAN class="operator token">+</SPAN> label <SPAN class="operator token">+</SPAN> <SPAN class="string token">"m"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> geom <SPAN class="operator token">+</SPAN> <SPAN class="string token">"-"</SPAN> <SPAN class="operator token">+</SPAN> label <SPAN class="operator token">+</SPAN> <SPAN class="string token">"m"</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></SPAN></SPAN>
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.