Edit features with feature-linked annotation

View inWPFUWPFormsiOSAndroid
View on GitHub

Edit feature attributes which are linked to annotation through an expression.

Image of edit features with feature-linked annotation

Use case

Annotation is useful for displaying text that you don't want to move or resize when the map is panned or zoomed (unlike labels which will move and resize). Feature-linked annotation will update when a feature attribute referenced by the annotation expression is also updated. Additionally, the position of the annotation will transform to match any transformation to the linked feature's geometry.

How to use the sample

Pan and zoom the map to see that the text on the map is annotation, not labels. Tap one of the address points to update the house number (ADADDRESS) and street name (STSTR_NAM). Tap one of the dashed parcel polylines and tap another location to change its geometry. NOTE: Selection is only enabled for points and straight (single segment) polylines.

The feature-linked annotation will update accordingly.

How it works

  1. Load the geodatabase. NOTE: Read/write geodatabases should normally come from a GeodatabaseSyncTask, but this has been omitted here. That functionality is covered in the sample Generate geodatabase.
  2. Create FeatureLayers from geodatabase feature tables found in the geodatabase with geodatabase.GeodatabaseFeatureTable.
  3. Create AnnotationLayers from geodatabase feature tables found in the geodatabase with geodatabase.GeodatabaseAnnotationTable.
  4. Add the FeatureLayers and AnnotationLayers to the map's operational layers.
  5. Use a GeoViewTapped event handler to listen for clicks on the map to either select address points or parcel polyline features. NOTE: Selection is only enabled for points and straight (single segment) polylines.

    • For the address points, a dialog is opened to allow editing of the address number (ADADDRESS) and street name (STSTR_NAM) attributes.
    • For the parcel lines, a second tap will change one of the polyline's vertices.

Both expressions were defined by the data author in ArcGIS Pro using the Arcade expression language.

Relevant API

  • AnnotationLayer
  • Feature
  • FeatureLayer
  • Geodatabase

Offline data

This sample downloads the following items from ArcGIS Online automatically:

About the data

This sample uses data derived from the Loudoun GeoHub.

The annotation linked to the point data in this sample is defined by arcade expression $feature.AD_ADDRESS + " " + $feature.ST_STR_NAM. The annotation linked to the parcel polyline data is defined by Round(Length(Geometry($feature), 'feet'), 2).

Tags

annotation, attributes, features, feature-linked annotation, fields

Sample Code

EditAttributeLayout.xmlEditFeatureLinkedAnnotation.cs
                                           
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/addressNumberTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:text="AD_ADDRESS"
        app:layout_constraintBottom_toBottomOf="@+id/addressNumberEditText"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/addressNumberEditText" />
    <EditText
        android:id="@+id/addressNumberEditText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:inputType="number"
        android:labelFor="@id/addressNumberTextView"
        app:layout_constraintStart_toEndOf="@+id/addressNumberTextView"
        app:layout_constraintTop_toTopOf="parent" />
    <TextView
        android:id="@+id/streetTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ST_STR_NAM"
        app:layout_constraintBottom_toBottomOf="@+id/streetEditText"
        app:layout_constraintEnd_toEndOf="@+id/addressNumberTextView"
        app:layout_constraintTop_toTopOf="@+id/streetEditText" />
    <EditText
        android:id="@+id/streetEditText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:inputType="text"
        android:labelFor="@id/streetTextView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@+id/streetTextView"
        app:layout_constraintTop_toBottomOf="@+id/addressNumberEditText" />
</androidx.constraintlayout.widget.ConstraintLayout>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.