private async void OpenMMPK1() { // Mobile map package to open directly from a package or an unpacked folder. MobileMapPackage mobileMapPackage; // Check whether the mobile map package supports direct read. bool isDirectReadSupported = await MobileMapPackage.IsDirectReadSupportedAsync(pathToOutputPackage); if (isDirectReadSupported) { // If it does, create the mobile map package directly from the .mmpk file. mobileMapPackage = await MobileMapPackage.OpenAsync(pathToOutputPackage); } else { // Otherwise, unpack the mobile map package file into a directory. await MobileMapPackage.UnpackAsync(pathToOutputPackage, pathToUnpackedPackage); // Create the mobile map package from the unpack directory. mobileMapPackage = await MobileMapPackage.OpenAsync(pathToUnpackedPackage); } // Make sure there is at least one map, then add the first map in the package to the map view. if (mobileMapPackage.Maps.Count > 0) { Map myMap = mobileMapPackage.Maps.First(); MyMapView.Map = myMap; } }
private async Task <MobileMapPackage> OpenMobileMapPackage(string path) { // Load directly or unpack then load as needed by the map package. if (await MobileMapPackage.IsDirectReadSupportedAsync(path)) { // Open the map package. MobileMapPackage package = await MobileMapPackage.OpenAsync(path); // Load the package. await package.LoadAsync(); // Return the opened package. return(package); } else { // Create a path for the unpacked package. string unpackedPath = path + "unpacked"; // Unpack the package. await MobileMapPackage.UnpackAsync(path, unpackedPath); // Open the package. MobileMapPackage package = await MobileMapPackage.OpenAsync(unpackedPath); // Load the package. await package.LoadAsync(); // Return the opened package. return(package); } }
private async void OpenMMPK() { var filepath = mapClass.Filepath; Basemap heatBase = Basemap.CreateImageryWithLabels(); try { // Load directly or unpack then load as needed by the map package. if (await MobileMapPackage.IsDirectReadSupportedAsync(filepath)) { // Open the map package. MobileMapPackage heatMap = await MobileMapPackage.OpenAsync(filepath); Map HeatVulnerabilityMap = heatMap.Maps.First(); // Check for map in .mmpk and give to corresponding views if (heatMap.Maps.Count > 0) { HeatVuln.Map = HeatVulnerabilityMap; HeatVuln.Map.Basemap = heatBase; HeatVuln.Map.OperationalLayers[0].IsVisible = false; // Avg Temp / Daily Heating HeatVuln.Map.OperationalLayers[1].IsVisible = false; // Impervous Surfaces HeatVuln.Map.OperationalLayers[2].IsVisible = false; // Tree Canopy HeatVuln.Map.OperationalLayers[3].IsVisible = true; // Heat Vulnerability HeatVuln.Map.OperationalLayers[4].IsVisible = false; // Richmond Poverty } } else { // Create a path for the unpacked package. string unpackedPath = filepath + "unpacked"; // Unpack the package. await MobileMapPackage.UnpackAsync(filepath, unpackedPath); // Open the package. MobileMapPackage package = await MobileMapPackage.OpenAsync(unpackedPath); // Load the package. await package.LoadAsync(); } } catch (Exception e) { System.Windows.MessageBox.Show(e.ToString(), "Error"); } }
private async void Initialize() { // Get the path to the mobile map package. string filepath = GetMmpkPath(); try { // Load directly or unpack then load as needed by the map package. if (await MobileMapPackage.IsDirectReadSupportedAsync(filepath)) { // Open the map package. MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(filepath); // Display the first map in the package. MyMapView.Map = myMapPackage.Maps.First(); } else { // Create a path for the unpacked package. string unpackedPath = filepath + "unpacked"; // Unpack the package. await MobileMapPackage.UnpackAsync(filepath, unpackedPath); // Open the package. MobileMapPackage package = await MobileMapPackage.OpenAsync(unpackedPath); // Load the package. await package.LoadAsync(); // Show the first map. MyMapView.Map = package.Maps.First(); } } catch (Exception e) { await((Page)Parent).DisplayAlert("Error", e.ToString(), "OK"); } }
private async void Initialize() { // Get the path to the mobile map package. string filepath = GetMmpkPath(); try { // Load directly or unpack then load as needed by the map package. if (await MobileMapPackage.IsDirectReadSupportedAsync(filepath)) { // Open the map package. MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(filepath); // Display the first map in the package. _myMapView.Map = myMapPackage.Maps.First(); } else { // Create a path for the unpacked package. string unpackedPath = filepath + "unpacked"; // Unpack the package. await MobileMapPackage.UnpackAsync(filepath, unpackedPath); // Open the package. MobileMapPackage package = await MobileMapPackage.OpenAsync(unpackedPath); // Load the package. await package.LoadAsync(); // Show the first map. _myMapView.Map = package.Maps.First(); } } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
private async void Initialize() { // Get the path to the mobile map package. string filepath = DataManager.GetDataFolder("e1f3a7254cb845b09450f54937c16061", "Yellowstone.mmpk"); try { // Load directly or unpack then load as needed by the map package. if (await MobileMapPackage.IsDirectReadSupportedAsync(filepath)) { // Open the map package. MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(filepath); // Display the first map in the package. _myMapView.Map = myMapPackage.Maps.First(); } else { // Create a path for the unpacked package. string unpackedPath = filepath + "unpacked"; // Unpack the package. await MobileMapPackage.UnpackAsync(filepath, unpackedPath); // Open the package. MobileMapPackage package = await MobileMapPackage.OpenAsync(unpackedPath); // Load the package. await package.LoadAsync(); // Show the first map. _myMapView.Map = package.Maps.First(); } } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }