Re-using already downloaded map (on-demand)

580
2
Jump to solution
02-15-2022 04:30 AM
stettdev
New Contributor

I'm using ArcGIS Runtime for .NET with WPF UI framework, version 100.13.0 and I am trying to re-use the map files downloaded with code from this tutorial: Display an offline map (on-demand). After looking through the downloaded files I found the .mmap file which, I assume, is a Mobile Map file. Does this have anything to do with mobile map packages? Is my app destined to re-download the AOI for offline use on each launch?

0 Kudos
2 Solutions

Accepted Solutions
JoeHershman
MVP Regular Contributor

You can either download a new copy of the map, or open what exists on the device.  If you open the offline map it would not download a new version, you have to explicitly download

MobileMapPackage localMapArea = await MobileMapPackage.OpenAsync(mapPackagePath);
//assuming a single map in map package
var map = localMapArea.Maps.First();
await map.LoadAsync();
//This just makes sure all the FeatureLayers are loaded
map.OperationalLayers.ToList().ForEach(async l => await l.LoadAsync());
Thanks,
-Joe

View solution in original post

Nicholas-Furness
Esri Regular Contributor

When you download an offline map using the OfflineMapTask, Runtime will create a folder at the location you specify when you create the new GenerateOfflineMapJob, and will download and write a number of resources into that folder. As you noticed, there is a .mmap file, but you should consider the folder to be a black box.

To re-use the already downloaded offline map, as @JoeHershman shows below, you create a new MobileMapPackage with the same folder you specified when you downloaded the offline map. Then get the first map from it. See this documentation for more info.

Note, you do not need to explicitly load the map or its operational layers unless you plan on reading their metadata before they are displayed in a map view.

View solution in original post

2 Replies
JoeHershman
MVP Regular Contributor

You can either download a new copy of the map, or open what exists on the device.  If you open the offline map it would not download a new version, you have to explicitly download

MobileMapPackage localMapArea = await MobileMapPackage.OpenAsync(mapPackagePath);
//assuming a single map in map package
var map = localMapArea.Maps.First();
await map.LoadAsync();
//This just makes sure all the FeatureLayers are loaded
map.OperationalLayers.ToList().ForEach(async l => await l.LoadAsync());
Thanks,
-Joe
Nicholas-Furness
Esri Regular Contributor

When you download an offline map using the OfflineMapTask, Runtime will create a folder at the location you specify when you create the new GenerateOfflineMapJob, and will download and write a number of resources into that folder. As you noticed, there is a .mmap file, but you should consider the folder to be a black box.

To re-use the already downloaded offline map, as @JoeHershman shows below, you create a new MobileMapPackage with the same folder you specified when you downloaded the offline map. Then get the first map from it. See this documentation for more info.

Note, you do not need to explicitly load the map or its operational layers unless you plan on reading their metadata before they are displayed in a map view.