Map scale in Arcade labels

982
5
11-13-2017 03:06 AM
GarethBaker1
Occasional Contributor II

I'd like to be able to include the current map scale in the labels for a feature in Portal 10.5.1. The documentation on this page suggests that only the feature to be labelled is available as a global variable in Arcade expression

https://developers.arcgis.com/arcade/guide/profiles/#labelling

However within the playground section on the same site the current map scale is available under the labelling profile

Map scale available in Arcade expression on playground site

If I try to use the map scale global in an Arcade label expression on a layer in a Portal 10.5.1 web map I get an error about the view identifier not being found.

View scale not available in Portal 10.5.1 Arcade

I'm guessing that the reason it works in the playground is that the page is built with the JS API and that has a slightly different implementation of Arcade than Portal 10.5.1 perhaps? My question is will the map scale global be available in later versions of Portal?

5 Replies
JeffreySutherland
Esri Contributor

Hi Gareth,

I'd like to be able to include the current map scale in the labels for a feature in Portal 10.5.1. The documentation on this page suggests that only the feature to be labelled is available as a global variable in Arcade expression

https://developers.arcgis.com/arcade/guide/profiles/#labelling

 

However within the playground section on the same site the current map scale is available under the labelling profile. If I try to use the map scale global in an Arcade label expression on a layer in a Portal 10.5.1 web map I get an error about the view identifier not being found.

You are correct here - the only global variable currently available for the labeling profile is $feature and the global $view.scale will not work in Portal 10.5.1. There is a bug in the playground environment and we are actively working to correct that. Thanks for pointing it out!

My question is will the map scale global be available in later versions of Portal?


As of now there are no concrete plans for adding $view.scale to the labeling profile. If you don't mind me asking, what is your use case for wanting to include current map scale in labels for a feature in 10.5.1? 

Hope this helps!

Thanks,

Jeff

GarethBaker1
Occasional Contributor II

Thanks for the response Jeffrey.  I was actually (slightly randomly) looking at the scale in Arcade as a way of displaying the map scale to the user - I thought I could have a very large transparent polygon that covered my map extent and was labelled with the scale value.  This is because the scalebar widget in Web App Builder doesn't have an option to show the scale as text, which is something that our Portal users tell us that they want to see. I thought the Arcade option might be quicker than trying to write a custom widget but it doesn't look like it is an option in this case.

However I could also potentially see a scenario where someone might want to adjust the label string at smaller scales e.g. abbreviate Street to St or maybe choose not to show a particular label if it was over a certain number of characters.

0 Kudos
JaredSchuckert
Occasional Contributor

I would like to access map scale in order to create label classes for a hosted feature layer in Portal. So for example, if below x scale label "xyz" if above x scale label just "xy". It looks like there is access to map scale for symbology purposes, although not for labels is this correct? Any thoughts would be greatly appreciated! 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi jschuckert_InterwestGIS ,

As you already have noticed, this is not yet possible. Although there is an idea: Scale-based symbology and labeling in AGOL , but you already found and up-voted that idea (so did I just now). 

The only thing I can think of at this moment is to duplicate the layer, each with its own label expression and scale dependency. So when you zoom in, for instance layer1 becomes visible (layer2 is not) and shows the larger label text and when you zoom out layer2 becomes visible with the shorter labels (and layer1 will switch off).

However, it is a great use case and it would be great to have this functionality in the Arcade label profile!

0 Kudos
JaredSchuckert
Occasional Contributor

Xander,

Thank you for the reply and idea, I may just try that for this particular case. I will keep an eye out for future Arcade solutions as well. Thanks!