private void WebMapListView_ItemSelected(object sender, AdapterView.ItemClickEventArgs e) { // When a row in the list is selected, get the associated web map item. PortalItemAdapter itemAdapter = _webMapListView.Adapter as PortalItemAdapter; PortalItem selectedItem = itemAdapter[e.Position]; // Create a new map from the portal item and display it in the map view. Map webMap = new Map(selectedItem); _myMapView.Map = webMap; }
private async void SearchPortal(ArcGISPortal currentPortal) { // Show status message. _messagesTextView.Text = "Searching for web map items on the portal at " + currentPortal.Uri.AbsoluteUri; var messageBuilder = new StringBuilder(); try { // Report connection info. messageBuilder.AppendLine("Connected to the portal on " + currentPortal.Uri.Host); // Report the user name used for this connection. if (currentPortal.User != null) { messageBuilder.AppendLine("Connected as: " + currentPortal.User.UserName); } else { // Note: This shouldn't happen for a secure portal! messageBuilder.AppendLine("Anonymous"); } // Search the portal for web maps. var items = await currentPortal.FindItemsAsync(new PortalQueryParameters("type:(\"web map\" NOT \"web mapping application\")")); // Build a list of items from the results. var resultItems = from r in items.Results select new KeyValuePair <string, PortalItem>(r.Title, r); // Add the items to a dictionary. List <PortalItem> webMapItems = new List <PortalItem>(); foreach (var itm in resultItems) { webMapItems.Add(itm.Value); } // Create an array adapter for the result list. PortalItemAdapter adapter = new PortalItemAdapter(this, webMapItems); // Apply the adapter to the list view to show the results. _webMapListView.Adapter = adapter; } catch (Exception ex) { // Report errors searching the portal. messageBuilder.AppendLine(ex.Message); } finally { // Show messages. _messagesTextView.Text = messageBuilder.ToString(); } }