Mobile map (search and route)

View inQMLC++
View on GitHub
Sample viewer app

Display maps and use locators to enable search and routing offline using a Mobile Map Package.

screenshot

Use case

Mobile map packages make it easy to transmit and store the necessary components for an offline map experience including: transportation networks (for routing/navigation), locators (address search, forward and reverse geocoding), and maps.

A field worker might download a mobile map package to support their operations while working offline.

How to use the sample

A list of maps from a mobile map package will be displayed. If the map contains transportation networks, the list item will have a navigation icon. Click on a map in the list to open it. If a locator task is available, click on the map to place a point. Click it again to reverse geocode the location's address. If transportation networks are available, click the route icon in the top right corner a route will be calculated between geocode locations.

How it works

  1. Create a MobileMapPackage passing in the path to the constructor.
  2. Get a list model of maps inside the package using the maps property.
  3. If the package has a locator, access it using the LocatorTask property.
  4. To see if a map contains transportation networks, check each map's TransportationNetworks property.

Relevant API

  • GeocodeResult
  • MobileMapPackage
  • ReverseGeocodeParameters
  • Route
  • RouteParameters
  • RouteResult
  • RouteTask
  • TransportationNetworkDataset

Offline data

Read more about how to set up the sample's offline data here.

Link Local Location
Yellowstone mmpk File <userhome>/ArcGIS/Runtime/Data/mmpk/Yellowstone.mmpk
SanFrancisco mmpk File <userhome>/ArcGIS/Runtime/Data/mmpk/SanFrancisco.mmpk

Tags

disconnected, field mobility, geocode, network, network analysis, offline, routing, search, transportation

Sample Code

MobileMap_SearchAndRoute.qmlMobileMap_SearchAndRoute.cppMobileMap_SearchAndRoute.h
                                                                                                                                                                                                                                                                                                                                                                                                  
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
// [WriteFile Name=MobileMap_SearchAndRoute, Category=Maps]
// [Legal]
// Copyright 2016 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0
import Esri.ArcGISRuntime.Toolkit 100.11

MobileMap_SearchAndRouteSample {
    id: mobileMapSearchRoute
    clip: true
    width: 800
    height: 600

    property bool isMapOpen: false

    // make background a light gray
    Rectangle {
        anchors.fill: parent
        color: "#E0E0E0"

        // add a mapView component
        MapView {
            id: mapView
            objectName: "mapView"

            // callout to display information
            Callout {
                calloutData: mapView.calloutData
                screenOffsetY: -19
                accessoryButtonHidden: true
                leaderPosition: leaderPositionEnum.Automatic
            }

            Rectangle {
                anchors {
                    left: parent.left
                    top: parent.top
                }
                opacity: 0.50
                height: parent.height
                width: 25
                color: "#E0E0E0"

                Rectangle {
                    anchors {
                        left: parent.left
                        top: parent.top
                    }
                    width: parent.width
                    height: 100
                    color: "#283593"

                    Image {
                        anchors.centerIn: parent
                        mirror: true
                        source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/forwardIcon.png"
                        height: 33
                        width: height
                    }
                }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        mapSelectionStack.pop();
                    }
                }
            }

            // Map controls
            Column {
                anchors {
                    top: parent.top
                    right: parent.right
                    margins: 10
                }
                spacing: 10

                // solve route button
                Rectangle {
                    id: routeButton
                    color: "#E0E0E0"
                    height: 50
                    width: height
                    border.color: "black"
                    radius: 2
                    opacity: 0.90
                    visible: mobileMapSearchRoute.canRoute

                    Image {
                        anchors {
                            centerIn: parent
                            margins: 5
                        }
                        source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/routingSymbol.png"
                        height: 44
                        width: height
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            mobileMapSearchRoute.solveRoute();
                        }
                    }
                }

                // clear graphics button
                Rectangle {
                    id: clearButton
                    color: "#E0E0E0"
                    height: 50
                    width: height
                    border.color: "black"
                    radius: 2
                    opacity: 0.90
                    visible: mobileMapSearchRoute.canClear

                    Image {
                        anchors {
                            centerIn: parent
                            margins: 5
                        }
                        source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/discardSymbol.png"
                        height: 44
                        width: height
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            mobileMapSearchRoute.resetMapView();
                        }
                    }
                }
            }
        }

        // use a StackView for the user interface
        StackView {
            id: mapSelectionStack
            anchors.fill: parent

            // begin with the mobile map package selection options
            initialItem: Item {

                Column {
                    anchors {
                        top: parent.top
                        left: parent.left
                    }
                    width: parent.width
                    spacing: 20

                    // UI navigation bar
                    Rectangle {
                        width: parent.width
                        height: 100
                        color: "#283593"

                        // forward navigation button. Visible after first map is selected
                        Image {
                            anchors {
                                verticalCenter: parent.verticalCenter
                                right: parent.right
                                margins: 10
                            }
                            source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/forwardIcon.png"
                            height: 44
                            width: height
                            visible: isMapOpen

                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    mapSelectionStack.push(mapSelectView);
                                }
                            }
                        }

                        Text {
                            anchors.centerIn: parent
                            color: "white"
                            height: 40
                            font.pixelSize: 25
                            text: "Choose a Mobile Map Package"
                        }
                    }

                    // mobile map package ListView
                    ListView {
                        anchors.horizontalCenter: parent.horizontalCenter
                        height: 400
                        width: 200
                        spacing: 10
                        model: mobileMapSearchRoute.mmpkList

                        delegate: Component {
                            Rectangle {

                                width: 200
                                height: 50
                                color: "#283593"
                                radius: 2
                                border.color: "darkgray"

                                Text {
                                    anchors.centerIn: parent
                                    horizontalAlignment: Text.AlignHCenter
                                    color: "white"
                                    width: 150
                                    text: modelData
                                    elide: Text.ElideMiddle
                                }

                                MouseArea {
                                    anchors.fill: parent
                                    propagateComposedEvents: false
                                    onClicked: {
                                        isMapOpen = false;

                                        //generate list of maps and go to map selection view
                                        mobileMapSearchRoute.createMapList(index);
                                        mapSelectionStack.push(mapSelectView);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Item {
                id: mapSelectView

                Column {
                    anchors {
                        top: parent.top
                        left: parent.left
                    }
                    width: parent.width
                    spacing: 20

                    // UI navigation bar
                    Rectangle {
                        width: parent.width
                        height: 100
                        color: "#283593"

                        // back button
                        Image {
                            anchors {
                                verticalCenter: parent.verticalCenter
                                left: parent.left
                                margins: 10
                            }
                            mirror: true
                            source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/forwardIcon.png"
                            height: 44
                            width: height

                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    mapSelectionStack.pop();
                                }
                            }
                        }

                        // forward button. Only visible after first map has been selected
                        Image {
                            anchors {
                                verticalCenter: parent.verticalCenter
                                right: parent.right
                                margins: 10
                            }
                            source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/forwardIcon.png"
                            height: 44
                            width: height
                            visible: isMapOpen

                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    mapSelectionStack.push(mapView);
                                }
                            }
                        }

                        Text {
                            anchors.centerIn: parent
                            color: "white"
                            height: 40
                            font.pixelSize: 25
                            text: "Choose a Map"
                        }
                    }

                    // list of maps
                    ListView {
                        anchors.horizontalCenter: parent.horizontalCenter
                        height: 400
                        width: 200
                        spacing: 10
                        model: mobileMapSearchRoute.mapList

                        delegate: Component {
                            Rectangle {
                                width: 200
                                height: 50
                                color: "#283593"
                                radius: 2
                                border.color: "darkgray"

                                Text {
                                    anchors.centerIn: parent
                                    horizontalAlignment: Text.AlignHCenter
                                    color: "white"
                                    width: 150
                                    text: modelData.name
                                    elide: Text.ElideMiddle
                                }

                                // geocoding available icon
                                Image {
                                    anchors {
                                        left: parent.left
                                        top: parent.top
                                        margins: 5
                                    }
                                    source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/pinOutlineSymbol.png"
                                    height: 20
                                    width: height
                                    visible: modelData.geocoding
                                }

                                // routing available icon
                                Image {
                                    anchors {
                                        right: parent.right
                                        top: parent.top
                                        margins: 5
                                    }
                                    source: "qrc:/Samples/Maps/MobileMap_SearchAndRoute/routingSymbol.png"
                                    height: 20
                                    width: height
                                    visible: modelData.routing
                                }

                                MouseArea {
                                    anchors.fill: parent
                                    propagateComposedEvents: false
                                    onClicked: {
                                        // set map and display mapView
                                        mobileMapSearchRoute.selectMap(index);
                                        isMapOpen = true;
                                        mapSelectionStack.push(mapView);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        BusyIndicator {
            anchors.centerIn: parent
            visible: mobileMapSearchRoute.isGeocodeInProgress
        }
    }
}

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