-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate offline map with custom parameters #314
Open
TADraeseke
wants to merge
12
commits into
v.next
Choose a base branch
from
trev8939/generateOfflineMapWithCustomParameters
base: v.next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7c1d22d
code and UI complete
TADraeseke ff6acad
Merge branch 'v.next' into trev8939/generateOfflineMapWithCustomParam…
TADraeseke 704becc
update README and metadata
TADraeseke 49aedc3
pull from origin
TADraeseke c5ebe97
pull from origin
TADraeseke bd0e3e5
fix title in README
TADraeseke 019131d
update screenshot
TADraeseke 0bc248e
update metadata
TADraeseke fe04317
basemap as layer not feature layer
TADraeseke 348494a
fix name
TADraeseke 5108b75
disable map rotation, handle reset state and other PR fixes
TADraeseke f7266f8
fix sliders and separate UI with dividers
TADraeseke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
samples/generate-offline-map-with-custom-parameters/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,63 @@ | ||||||
# Generate offline map with custom parameters | ||||||
|
||||||
Take a web map offline with additional options for each layer. | ||||||
|
||||||
![Image of generate offline map with custom parameters](generate-offline-map-with-custom-parameters.png) | ||||||
|
||||||
## 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 | ||||||
|
||||||
To 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`. | ||||||
2. Create an `OfflineMapTask` with the map. | ||||||
3. Generate default task parameters using the extent area you want to download with `offlineMapTask.createDefaultGenerateOfflineMapParameters(areaOfInterest)`. | ||||||
4. Generate additional "override" parameters using the default parameters with `offlineMapTask.createGenerateOfflineMapParameterOverrides(generateOfflineMapParameters)`. | ||||||
5. For the basemap: | ||||||
* Get the parameters `OfflineMapParametersKey` for the basemap layer. | ||||||
* Get the `ExportTileCacheParameters` for the basemap layer with `parameterOverrides.exportTileCacheParameters[basemapParamKey]`. | ||||||
* Set the level IDs you want to download with `exportTileCacheParameters.levelIds.add(...)`. | ||||||
* To buffer the extent, use `exportTileCacheParameters.areaOfInterest` where bufferedGeometry 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 `parameterOverrides.generateGeodatabaseParameters[key].layerOptions` | ||||||
* Using the `GenerateLayerOption` list, and remove the layer if its the layer option's ID matches the layer's ID. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
7. To filter the features downloaded in an operational layer: | ||||||
* Get the layer options for the operational layer using the directions in step 6. | ||||||
* For the desired layer, set the filter clause with `generateLayerOption.whereClause(...)` and set the query option with `generateLayerOption.queryOption = GenerateLayerQueryOption.UseFilter`. | ||||||
8. To not crop a layer's features to the extent of the offline map (default is true): | ||||||
* Set `layerOption.generateLayerOption = true`. | ||||||
9. Create a `GenerateOfflineMapJob` with `offlineMapTask.createGenerateOfflineMapJob(parameters, offlineMapPath, parameterOverrides`. Start the GenerateOfflineMapJob with `offlineMapJob.start()`. You can collect on the job's progress to update a progress bar in your UI. | ||||||
10. When the job is done, check `offlineMapJob.result().onSuccess { ... }` to get a reference to the `offlineMap`. | ||||||
|
||||||
## Relevant API | ||||||
|
||||||
* ExportTileCacheParameters | ||||||
* GenerateGeodatabaseParameters | ||||||
* GenerateLayerOption | ||||||
* GenerateOfflineMapJob | ||||||
* GenerateOfflineMapParameterOverrides | ||||||
* GenerateOfflineMapParameters | ||||||
* 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 |
50 changes: 50 additions & 0 deletions
50
samples/generate-offline-map-with-custom-parameters/README.metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"category": "Edit and Manage Data", | ||
"description": "Take a web map offline with additional options for each layer.", | ||
"formal_name": "GenerateOfflineMapWithCustomParameters", | ||
"ignore": false, | ||
"images": [ | ||
"generate-offline-map-with-custom-parameters.png" | ||
], | ||
"keywords": [ | ||
"LOD", | ||
"adjust", | ||
"download", | ||
"extent", | ||
"filter", | ||
"offline", | ||
"override", | ||
"parameters", | ||
"reduce", | ||
"scale range", | ||
"setting", | ||
"ExportTileCacheParameters", | ||
"GenerateGeodatabaseParameters", | ||
"GenerateLayerOption", | ||
"GenerateOfflineMapJob", | ||
"GenerateOfflineMapParameterOverrides", | ||
"GenerateOfflineMapParameters", | ||
"OfflineMapParametersKey", | ||
"OfflineMapTask" | ||
], | ||
"language": "kotlin", | ||
"redirect_from": [ | ||
"" | ||
], | ||
"relevant_apis": [ | ||
"ExportTileCacheParameters", | ||
"GenerateGeodatabaseParameters", | ||
"GenerateLayerOption", | ||
"GenerateOfflineMapJob", | ||
"GenerateOfflineMapParameterOverrides", | ||
"GenerateOfflineMapParameters", | ||
"OfflineMapParametersKey", | ||
"OfflineMapTask" | ||
], | ||
"snippets": [ | ||
"src/main/java/com/esri/arcgismaps/sample/generateofflinemapwithcustomparameters/components/GenerateOfflineMapWithCustomParametersViewModel.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/generateofflinemapwithcustomparameters/MainActivity.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/generateofflinemapwithcustomparameters/screens/GenerateOfflineMapWithCustomParametersScreen.kt" | ||
], | ||
"title": "Generate offline map with custom parameters" | ||
} |
22 changes: 22 additions & 0 deletions
22
samples/generate-offline-map-with-custom-parameters/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
alias(libs.plugins.arcgismaps.android.library) | ||
alias(libs.plugins.arcgismaps.android.library.compose) | ||
alias(libs.plugins.arcgismaps.kotlin.sample) | ||
alias(libs.plugins.gradle.secrets) | ||
} | ||
|
||
secrets { | ||
// this file doesn't contain secrets, it just provides defaults which can be committed into git. | ||
defaultPropertiesFileName = "secrets.defaults.properties" | ||
} | ||
|
||
android { | ||
namespace = "com.esri.arcgismaps.sample.generateofflinemapwithcustomparameters" | ||
buildFeatures { | ||
buildConfig = true | ||
} | ||
} | ||
|
||
dependencies { | ||
// Only module specific dependencies needed here | ||
} |
Binary file added
BIN
+293 KB
...line-map-with-custom-parameters/generate-offline-map-with-custom-parameters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
samples/generate-offline-map-with-custom-parameters/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application><activity | ||
android:exported="true" | ||
android:name=".MainActivity" | ||
android:label="@string/generate_offline_map_with_custom_parameters_app_name"> | ||
|
||
</activity> | ||
</application> | ||
|
||
</manifest> |
53 changes: 53 additions & 0 deletions
53
...in/java/com/esri/arcgismaps/sample/generateofflinemapwithcustomparameters/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Copyright 2025 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. | ||
* | ||
*/ | ||
|
||
package com.esri.arcgismaps.sample.generateofflinemapwithcustomparameters | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import com.arcgismaps.ApiKey | ||
import com.arcgismaps.ArcGISEnvironment | ||
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme | ||
import com.esri.arcgismaps.sample.generateofflinemapwithcustomparameters.screens.GenerateOfflineMapWithCustomParametersScreen | ||
|
||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
// authentication with an API key or named user is | ||
// required to access basemaps and other location services | ||
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN) | ||
|
||
setContent { | ||
SampleAppTheme { | ||
GenerateOfflineMapWithCustomParametersApp() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun GenerateOfflineMapWithCustomParametersApp() { | ||
Surface(color = MaterialTheme.colorScheme.background) { | ||
GenerateOfflineMapWithCustomParametersScreen( | ||
sampleName = getString(R.string.generate_offline_map_with_custom_parameters_app_name) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.