Generate offline map (overrides)

View inWPFUWPFormsiOSAndroid
View on GitHub

Take a web map offline with additional options for each layer.

Image of generate offline map overrides

Use case

When taking a web map offline, you may adjust the data (such as layers or tiles) that is downloaded by using custom parameter overrides. This can be used to reduce the extent of the map or the download size of the offline map. It can also be used to highlight specific data by removing irrelevant data. Additionally, this workflow allows you to take features offline that don't have a geometry - for example, features whose attributes have been populated in the office, but still need a site survey for their geometry.

How to use the sample

Modify the overrides parameters:

  • Use the min/max scale input fields to adjust the level IDs to be taken offline for the streets basemap.
  • Use the extent buffer distance input field to set the buffer radius for the streets basemap.
  • Check the checkboxes for the feature operational layers you want to include in the offline map.
  • Use the min hydrant flow rate input field to only download features with a flow rate higher than this value.
  • Select the "Water Pipes" checkbox if you want to crop the water pipe features to the extent of the map.

After you have set up the overrides to your liking, tap the "Generate offline map" button to start the download. A progress bar will display. Tap the "Cancel" button if you want to stop the download. When the download is complete, the view will display the offline map. Pan around to see that it is cropped to the download area's extent.

How it works

  1. Load a web map from a PortalItem. Authenticate with the portal if required.
  2. Create an OfflineMapTask with the map.
  3. Generate default task parameters using the extent area you want to download with offlineMapTask.CreateDefaultGenerateOfflineMapParametersAsync(extent).
  4. Generate additional "override" parameters using the default parameters with offlineMapTask.CreateGenerateOfflineMapParameterOverridesAsync(parameters).
  5. For the basemap:

    • Get the parameters OfflineMapParametersKey for the basemap layer.
    • Get the ExportTileCacheParameters for the basemap layer with overrides.ExportTileCacheParameters[basemapParamKey].
    • Set the level IDs you want to download with exportTileCacheParametersLevelIDs().Add(levelID).
    • To buffer the extent, set the exportTileCacheParameters.AreaOfInterest property. B uffered geometry can be calculated with the GeometryEngine.
  6. To remove operational layers from the download:

    • Create a OfflineParametersKey with the operational layer.
    • Get the generate geodatabase layer options using the key with List<GenerateLayerOption> layerOptions = overrides.GenerateGeodatabaseParameters[key].LayerOptions;
    • Loop through each GenerateLayerOption in the the list, and remove it if the layer option's ID matches the layer's ID.
  7. To filter the features downloaded in an operational layer:

    • Get the layer options for the operational layer using the directions in step 6.
    • Loop through the layer options. If the option LayerID matches the layer's ID, set the filter clause with layerOption.WhereClause property and set the query option with layerOption.QueryOption property.
  8. To not crop a layer's features to the extent of the offline map (default is true):

    • Set the layerOption.UseGeometry property to false.
  9. Create a GenerateOfflineMapJob with offlineMapTask.GenerateOfflineMap(parameters, downloadPath, overrides).
  10. Get a reference to the offline map with job.GetResultAsync()

Relevant API

  • ExportTileCacheParameters
  • GenerateGeodatabaseParameters
  • GenerateLayerOption
  • GenerateOfflineMapJob
  • GenerateOfflineMapParameterOverrides
  • GenerateOfflineMapParameters
  • GenerateOfflineMapResult
  • OfflineMapParametersKey
  • OfflineMapTask

Additional information

For applications where you just need to take all layers offline, use the standard workflow (using only GenerateOfflineMapParameters). For a simple example of how you take a map offline, please consult the "Generate offline map" sample.

Tags

adjust, download, extent, filter, LOD, offline, override, parameters, reduce, scale range, setting

Sample Code

OverrideParametersDialog.axmlGenerateOfflineMapWithOverrides.csParameterOverrideFragment.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/scrollView2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/adjustBasemapTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:text="Adjust the basemap"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/minScaleLevelTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="Min scale:"
            app:layout_constraintEnd_toEndOf="@+id/maxScaleTextView"
            app:layout_constraintTop_toBottomOf="@+id/adjustBasemapTextView" />

        <TextView
            android:id="@+id/maxScaleTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="Max scale:"
            app:layout_constraintEnd_toEndOf="@+id/extentBufferDistanceTextView"
            app:layout_constraintTop_toBottomOf="@+id/minScaleLevelTextView" />

        <TextView
            android:id="@+id/extentBufferDistanceTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="Buffer distance:"
            app:layout_constraintEnd_toEndOf="@+id/minHydrantFlowRateTextView"
            app:layout_constraintTop_toBottomOf="@+id/maxScaleTextView" />

        <TextView
            android:id="@+id/includeLayersTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:text="Include layers"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/extentBufferDistanceTextView" />

        <CheckBox
            android:id="@+id/systemValvesCheckBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginLeft="16dp"
            android:text="System valves"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/includeLayersTextView" />

        <CheckBox
            android:id="@+id/serviceConnectionsCheckBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginLeft="16dp"
            android:text="Service connections"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/systemValvesCheckBox" />

        <TextView
            android:id="@+id/filterFeatureLayerTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:text="Filter feature layer"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/serviceConnectionsCheckBox" />

        <TextView
            android:id="@+id/minHydrantFlowRateTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:text="Min. Flow Rate"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/filterFeatureLayerTextView" />

        <TextView
            android:id="@+id/cropLayerToExtentTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:text="Crop layer to extent"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/minHydrantFlowRateTextView" />

        <CheckBox
            android:id="@+id/waterPipesCheckBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginLeft="16dp"
            android:text="Water pipes"
			android:checked="true"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/cropLayerToExtentTextView" />

        <TextView
            android:id="@+id/currMinScaleTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginBottom="8dp"
            android:minWidth="80dp"
			android:text="0"
            app:layout_constraintBottom_toTopOf="@+id/maxScaleTextView"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/minScaleLevelTextView" />

        <SeekBar
            android:id="@+id/minScaleSeekBar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:max="23"
			android:progress="0"
            app:layout_constraintBottom_toBottomOf="@+id/minScaleLevelTextView"
            app:layout_constraintEnd_toStartOf="@+id/currMinScaleTextView"
            app:layout_constraintStart_toEndOf="@+id/minScaleLevelTextView"
            app:layout_constraintTop_toTopOf="@+id/minScaleLevelTextView" />

        <TextView
            android:id="@+id/currMaxScaleTextview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:minWidth="80dp"
			android:text="23"
            app:layout_constraintBottom_toBottomOf="@+id/maxScaleTextView"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/minScaleSeekBar"
            app:layout_constraintTop_toTopOf="@+id/maxScaleTextView" />

        <SeekBar
            android:id="@+id/maxScaleSeekBar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:max="23"
			android:progress="23"
            app:layout_constraintBottom_toBottomOf="@+id/maxScaleTextView"
            app:layout_constraintEnd_toStartOf="@+id/currMinScaleTextView"
            app:layout_constraintStart_toEndOf="@+id/maxScaleTextView"
            app:layout_constraintTop_toTopOf="@+id/maxScaleTextView" />

        <SeekBar
            android:id="@+id/extentBufferDistanceSeekBar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:max="500"
            app:layout_constraintBottom_toBottomOf="@+id/extentBufferDistanceTextView"
            app:layout_constraintEnd_toEndOf="@+id/maxScaleSeekBar"
            app:layout_constraintStart_toStartOf="@+id/maxScaleSeekBar"
            app:layout_constraintTop_toTopOf="@+id/extentBufferDistanceTextView" />

        <TextView
            android:id="@+id/currExtentBufferDistanceTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:minWidth="80dp"
			android:text="0"
            app:layout_constraintBottom_toBottomOf="@+id/extentBufferDistanceTextView"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/extentBufferDistanceTextView" />

        <SeekBar
            android:id="@+id/minHydrantFlowRateSeekBar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:max="999"
			android:progress="500"
            app:layout_constraintBottom_toBottomOf="@+id/minHydrantFlowRateTextView"
            app:layout_constraintEnd_toEndOf="@+id/extentBufferDistanceSeekBar"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="@+id/extentBufferDistanceSeekBar"
            app:layout_constraintTop_toTopOf="@+id/minHydrantFlowRateTextView" />

        <TextView
            android:id="@+id/currMinHydrantFlowRateTextView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:minWidth="80dp"
            android:minEms="2"
			android:text="500"
            app:layout_constraintBottom_toBottomOf="@+id/minHydrantFlowRateTextView"
            app:layout_constraintEnd_toEndOf="@+id/currExtentBufferDistanceTextView"
            app:layout_constraintStart_toStartOf="@+id/currExtentBufferDistanceTextView"
            app:layout_constraintTop_toTopOf="@+id/minHydrantFlowRateTextView" />

    </android.support.constraint.ConstraintLayout>
</ScrollView>

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