private async void OnSearchMapsClicked(object sender, OnSearchMapEventArgs e) { try { // Get web map portal items from a keyword search IEnumerable <PortalItem> mapItems = null; // Connect to the portal (anonymously) ArcGISPortal 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 string queryExpression = $"tags:\"{e.SearchText}\" access:public type: (\"web map\" NOT \"web mapping application\")"; // 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) { new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show(); } }
// A click handler for the search button private void SearchMapsButtonClick(object sender, EventArgs e) { try { // Get information for the new portal item string search = _mapSearchTextbox.Text; // Create a new OnSaveMapEventArgs object to store the information entered by the user OnSearchMapEventArgs mapSearchArgs = new OnSearchMapEventArgs(search); // Raise the OnSaveClicked event so the main activity can handle the event and save the map OnSearchClicked?.Invoke(this, mapSearchArgs); // Close the dialog Dismiss(); } catch (Exception ex) { // Show the exception message (dialog will stay open so user can try again) AlertDialog.Builder alertBuilder = new AlertDialog.Builder(Activity); alertBuilder.SetTitle("Error"); alertBuilder.SetMessage(ex.Message); alertBuilder.Show(); } }
private async void OnSearchMapsClicked(object sender, OnSearchMapEventArgs e) { // 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); }