Get rotation of map frame in arcade expression or how to rotate labels accordingly

2327
5
03-06-2021 12:32 AM
AndreasLorentzen
New Contributor III

Hi,

I have a map with data driven pages (Map series now?) in the Layout and several feature classes with different labels. All of the pages have different rotations defined by a rotation field in the controlling feature layer.

I have in practice two layers I care about:

  • Drillhole layer with "bubbles" which should be rotated 0*deg in reference to the layout. (normal Reading)
  • Profile numbers which should be rotated relative to the map north. These profile numbers have a rotation field which ensures them to be rotated correctly according to map north.

I thought I found a solution with the "Rotate point and polygon labels when map is rotated" in the label part of the map properties, however the effect is not desirable, as you can see in the figure:

AndreasLorentzen_1-1615019543898.png


After this defeat I tried for a while to find any solution in the Arcade environment to rotate some of the labels "back" to normal. I wanted to get an expression in arcade which gave me the rotation from the map frame. However, I have not found any way, mostly because the documentation on Arcade is limited, and I have yet to find any examples of what I can find with the $view or $layout part of arcade. I have read through a lot of the GitHub examples, but not anything there either (as far as I found).


The crux here is that I can't edit, or convert the datasets, as they should be dynamic to a feature service of which I have no control over. Otherwise I could just create lines out of the points and use line labels.

So, my question is as follows:
Are there any method of either:

  1. Use the "Rotate point and polygon labels when map is rotated" option on only selected layers?
  2. Use Arcade in a rotation field to access information (rotation) from the current map page?

 

Also, are there any documentation on what you can access with the $view in Arcade?

 

Tags (3)
0 Kudos
5 Replies
jcarlson
MVP Esteemed Contributor

This does seem like a significant issue. Even if you could get the map rotation using Arcade (which I think would be possible), I don't see a place where the rotation can be defined in the text formatting tags. How are you using your rotation field on the labels? Perhaps I'm just not seeing the same setting.

It seems to me what's missing here are property connections like we have in symbology.

jcarlson_0-1615039773307.png

Inelegant Workaround: Two Maps

There is a way around this for the time being.

  1. Create a copy of your map.
  2. Make all symbology transparent, and include your "straight" labels only.
  3. Turn off the "rotate labels with map" setting
  4. Add a second map frame to your layout, pointing to this map, and overlapping the first frame perfectly.
  5. Constrain the second map frame to match the scale, extent, and rotation of the first.

jcarlson_1-1615040481763.png

It's not perfect, not even close, and odds are some of your labels are going to overlap. But short of doing your map series with python, it might be the closest thing.

Still, I'm going to add an Idea for label class property connections, if you want to upvote it when it shows up. It would be a major benefit to situations like this.

- Josh Carlson
Kendall County GIS
AndreasLorentzen
New Contributor III

I haven't thought of that solution with a copy of the original map. How ever it is not that elegant. I don't think this will work well with many labels as it probably wont work in regard of overprinting and weight of labels.

A connection with properties is possible, however not with the map frames properties, however, would solve the problem.

Another thing that would solve the issue would be something similar to what you have in the format point symbol menu:

AndreasLorentzen_0-1615188080434.png

 

jcarlson
MVP Esteemed Contributor

Oh, that's an idea that I hadn't considered! Could you make one of the label classes a text symbol instead?

- Josh Carlson
Kendall County GIS
0 Kudos
AndreasLorentzen
New Contributor III

I think the only working workaround is to convert the lables to annotations. This worked well for the time, however, I have to do it every time someone want a change in the input dataset. So not an optimal solution. Maybe if no-on knows about a solution with arcade in a couple of days, I'll just add another improvement idea to implement something.


0 Kudos
jcarlson
MVP Esteemed Contributor

I added an Idea related to this if you want to give it an upvote. It does seem odd that labels won't connect to feature attributes outside of the font settings.

- Josh Carlson
Kendall County GIS