// Handle the SearchTextEntered event from the search input UI // SearchMapsEventArgs contains the search text that was entered private async void SearchTextEntered(object sender, SearchMapsEventArgs e) { try { // Get web map portal items from a keyword search IEnumerable <PortalItem> mapItems = null; ArcGISPortal portal; // Connect to the portal (anonymously) portal = await ArcGISPortal.CreateAsync(new Uri(ServerUrl)); // Create a query expression that will get public items of type 'web map' with the keyword(s) in the items tags var queryExpression = string.Format("tags:\"{0}\" access:public type: (\"web map\" NOT \"web mapping application\")", e.SearchText); // Create a query parameters object with the expression and a limit of 10 results PortalQueryParameters queryParams = new PortalQueryParameters(queryExpression, 10); // Search the portal using the query parameters and await the results PortalQueryResultSet <PortalItem> findResult = await portal.FindItemsAsync(queryParams); // Get the items from the query results mapItems = findResult.Results; // Show the map results ShowMapList(mapItems); } catch (Exception ex) { // Report search error UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } finally { // Get rid of the search input controls _searchMapsUI.Hide(); _searchMapsUI = null; } }
private void SearchCanceled(object sender, EventArgs e) { // Remove the search input UI. _searchMapsUi.Hide(); _searchMapsUi = null; }