Use annotation sublayers to gain finer control of annotation layer subtypes.
Annotation, which differs from labels by having a fixed place and size, is typically only relevant at particular scales. Annotation sublayers allow for finer control of annotation by allowing properties (like visibility in the map and legend) to be set and others to be read (like name) on subtypes of an annotation layer.
An annotation dataset which marks valves as "Opened" or "Closed", might be set to display the "Closed" valves over a broader range of scales than the "Opened" valves, if the "Closed" data is considered more relevant by the map's author. Regardless, the user can be given a manual option to set visibility of annotation sublayers on and off, if required.
Start the sample and take note of the visibility of the annotation. Zoom in and out to see the annotation turn on and off based on scale ranges set on the data.
Use the checkboxes to manually set "Open" and "Closed" annotation sublayers visibility to on or off.
- Load the
MobileMapPackage
. - Populate checkbox text with the
AnnotationSublayer
names (including maximum and minimum scales, where relevant). - Wire up the checkboxes to toggle the annotation sublayer's visibility.
- Add a listener for changes in map view navigation and add code to:
- Update the current scale UI element at the bottom of the screen on navigation.
- Set the "Open" annotation sublayer checkbox text to:
- Black, when the layer is drawn at the current map scale
- Light gray, when the layer is not drawn at the current map scale
- AnnotationLayer
- AnnotationSublayer
- LayerContent
This sample uses Gas Device Anno Mobile Map Package. It is downloaded from ArcGIS Online automatically before the sample runs.
The scale ranges were set by the map's author using ArcGIS Pro:
- The "Open" annotation sublayer has its maximum scale set to 1:500 and its minimum scale set to 1:2000.
- The "Closed" annotation sublayer has no minimum or maximum scales set, so will be drawn at all scales.
annotation, scale, text, utilities, visualization