Hi, I am new to ArcGIS development. I am trying to open map mobile package mmpk in uwp .net application. I have loaded the package in the map and I can see all the layers. Basemap is not part of mmpk package. I am unable to figure out how to display basemap with mmpk in UWP app. Can you help?
Hi,
I recommend the following guide topics:
Maps and scenes—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
Layers and tables—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
Layer types described—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
Work offline—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
Thanks
Mike
To add to Mike's documentation links…
Once you have the Map from the Mobile Map Package, it will have a Basemap property (it sounds like that will be unset). Look at the Basemap class and the factory methods on it (e.g. CreateNavigationVector or CreateImageryWithLabels) which will give you a Basemap object you can set on your Map's Basemap property.
To be safe, since I don't know what the content of your MMPK is, I would recommend setting the Basemap on the Map before you display the Map in the MapView*.
Hope this helps,
Nick.
* Technically, before the Map is "loaded". See here if you need to learn more about what this means in Runtime, but chances are you won't have to. When the map is "loaded" (not the same as reading it from the MMPK), its contents determine the Map's Spatial Reference and this is done by first inspecting the basemap.
Thanks for the response. As you mentioned I tried codes below. I am still unable to view basemap.
1. StorageFolder folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Pole");
StorageFile f = await folder.GetFileAsync("mmm.mmpk");
MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(f.Path);
Basemap b = Basemap.CreateImageryWithLabels();
myMapPackage.Maps.First().Basemap = b;
MyMapView.Map = myMapPackage.Maps.First();
2. StorageFolder folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Pole");
StorageFile f = await folder.GetFileAsync("mmm.mmpk");
MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(f.Path);
Basemap b = Basemap.CreateStreetsVector();
MyMapView.Map = myMapPackage.Maps.First();
MyMapView.Map.Basemap = b;
Thanks for sharing your MMPK. That helped. Your map has a spatial reference of WGS 84.
Your solution is to do this:
try
{
MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync("");
if (myMapPackage.LoadStatus != LoadStatus.Loaded && myMapPackage.LoadError != null)
{
//TODO
}
ArcGISPortal arcGISPortal = await ArcGISPortal.CreateAsync();
PortalItem portalItem = await PortalItem.CreateAsync(arcGISPortal, "02b1f120c3674bfe896ac81731be1739");
Basemap basemap = new Basemap(portalItem);
Map map = myMapPackage.Maps.First();
map.LoadStatusChanged += Map_LoadStatusChanged;
map.Basemap = basemap;
MyMapView.Map = map;
}
catch (Exception) { throw; }
Our default basemaps that you create from our Basemap factory methods are spatial reference Web Mercator. The map that is obtained from the MMPK already has its spatial reference set (which I did not expect, but it turns out that's the case with maps from an MMPK).
Hope this helps (thanks Michael Branscomb for the .NET code!)
I tried the code. It's working perfectly. Thank you so much.