View on GitHub Sample viewer app

Take a web map offline.

Use case

Taking a web map offline allows users continued productivity when their network connectivity is poor or nonexistent. For example, by taking a map offline, a field worker inspecting utility lines in remote areas could still access a feature’s location and attribute information.

How to use the sample

When the map loads, zoom to the extent you want to take offline. The red border shows the extent that will be downloaded. Tap the “Generate offline map” button to start the offline map job. The progress view will show the job’s progress. When complete, the offline map will replace the online map in the map view.

How it works

  1. Create a Map with a Portal item pointing to the web map.
  2. Create GenerateOfflineMapParameters specifying the download area geometry, minimum scale, and maximum scale.
  3. Create an OfflineMapTask with the map.
  4. Create the OfflineMapJob with OfflineMapTask::generateOfflineMap(params, downloadDirectoryPath) and start it with OfflineMapJob::start().
  5. When the job is done, get the offline map with OfflineMapJob::result()::offlineMap().

Relevant API

  • GenerateOfflineMapJob
  • GenerateOfflineMapParameters
  • GenerateOfflineMapResult
  • OfflineMapTask
  • Portal

About the data

The map used in this sample shows the stormwater network within Naperville, IL, USA, with cartography designed for web and mobile devices with offline support.

Additional information

The creation of the offline map can be fine-tuned using parameter overrides for feature layers, or by using local basemaps. For examples on these, please consult the samples, “Generate Offline Map (Overrides)” and “Generate offline map with local basemap”.

Tags

download, offline, save, web map

Sample Code

DownloadButton.qml DownloadButton.qml GenerateOfflineMap.cpp GenerateOfflineMap.h GenerateOfflineMap.qml GenerateWindow.qml main.cpp
// Copyright 2017 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.
import QtQuick
// Create the download button to export the tile cache
Rectangle {
property bool pressed: false
signal buttonClicked()
width: 190
height: 35
color: pressed ? "#959595" : "#D6D6D6"
radius: 5
border {
color: "#585858"
width: 1
}
Row {
anchors.fill: parent
spacing: 5
Image {
width: 38
height: width
source: "qrc:/Samples/Maps/GenerateOfflineMap/download.png"
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: "Generate Offline Map"
font.pixelSize: 14
color: "#474747"
}
}
MouseArea {
anchors.fill: parent
onPressed: downloadButton.pressed = true
onReleased: downloadButton.pressed = false
onClicked: {
buttonClicked();
}
}
}