private async void QueryMapAreas() { try { // Clear existing overlays _mapViewService.ClearOverlays(); // Clear existing areas (in case user wants to refresh results) MapAreas.Clear(); // Create new task to var offlineMapTask = await OfflineMapTask.CreateAsync(Map); // Get list of areas IReadOnlyList <PreplannedMapArea> preplannedMapAreas = await offlineMapTask.GetPreplannedMapAreasAsync(); // Create UI from the areas foreach (var preplannedMapArea in preplannedMapAreas.OrderBy(x => x.PortalItem.Title)) { // Load area to get the metadata await preplannedMapArea.LoadAsync(); // Using a custom model for easier visualization var model = new MapAreaModel(preplannedMapArea); MapAreas.Add(model); // Graphic that shows the area in the map var graphic = new Graphic(preplannedMapArea.AreaOfInterest, GetSymbolForColor(model.DisplayColor)); graphic.Attributes.Add("Name", preplannedMapArea.PortalItem.Title); _areasOverlay.Graphics.Add(graphic); } if (!preplannedMapAreas.Any()) { await _windowService.ShowAlertAsync("No preplanned map areas available."); } else { // Show the overlays on the map _mapViewService.AddGraphicsOverlay(_areasOverlay); // Zoom to the offline areas await _mapViewService.SetViewpointGeometryAsync(_areasOverlay.Extent, 20); } // Refresh commands RefreshCommands(); } catch (Exception ex) { await _windowService.ShowAlertAsync(ex.Message, "Couldn't query map areas"); } }