private async void GetMyMaps() { // Get web map portal items in the current user's folder IEnumerable <PortalItem> mapItems = null; ArcGISPortal portal; // Call a sub that will force the user to log in to ArcGIS Online (if they haven't already) var loggedIn = await EnsureLoggedInAsync(); if (!loggedIn) { return; } // Connect to the portal (will connect using the provided credentials) portal = await ArcGISPortal.CreateAsync(new Uri(ServerUrl)); // Get the user's content (items in the root folder and a collection of sub-folders) PortalUserContent myContent = await portal.User.GetContentAsync(); // Get the web map items in the root folder mapItems = from item in myContent.Items where item.Type == PortalItemType.WebMap select item; // Loop through all sub-folders and get web map items, add them to the mapItems collection foreach (PortalFolder folder in myContent.Folders) { IEnumerable <PortalItem> folderItems = await portal.User.GetContentAsync(folder.FolderId); mapItems.Concat(from item in folderItems where item.Type == PortalItemType.WebMap select item); } // Show the map results ShowMapList(mapItems); }
private async void GetMyMaps(object sender, EventArgs e) { // Call a sub that will force the user to log in to ArcGIS Online (if they haven't already) bool loggedIn = await EnsureLoggedInAsync(); if (!loggedIn) { return; } // Connect to the portal (will connect using the provided credentials) ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(ArcGISOnlineUrl)); // Get the user's content (items in the root folder and a collection of sub-folders) PortalUserContent myContent = await portal.User.GetContentAsync(); // Get the web map items in the root folder IEnumerable <PortalItem> mapItems = from item in myContent.Items where item.Type == PortalItemType.WebMap select item; // Loop through all sub-folders and get web map items, add them to the mapItems collection foreach (PortalFolder folder in myContent.Folders) { IEnumerable <PortalItem> folderItems = await portal.User.GetContentAsync(folder.FolderId); mapItems = mapItems.Concat(from item in folderItems where item.Type == PortalItemType.WebMap select item); } // Show the list of web maps MapsListView.ItemsSource = mapItems; MapsListView.IsVisible = true; }
private async void SearchButton_Click(object sender, RoutedEventArgs e) { // Get web map portal items in the current user's folder or from a keyword search IEnumerable <PortalItem> mapItems = null; ArcGISPortal portal; // See if the user wants to search public web map items if (SearchPublicMaps.IsChecked == true) { // Connect to the portal (anonymously) portal = await ArcGISPortal.CreateAsync(); // 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\")", SearchText.Text); // 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; } else { // Call a sub that will force the user to log in to ArcGIS Online (if they haven't already) var loggedIn = await EnsureLoggedInAsync(); if (!loggedIn) { return; } // Connect to the portal (will connect using the provided credentials) portal = await ArcGISPortal.CreateAsync(new Uri(ArcGISOnlineUrl)); // Get the user's content (items in the root folder and a collection of sub-folders) PortalUserContent myContent = await portal.User.GetContentAsync(); // Get the web map items in the root folder mapItems = from item in myContent.Items where item.Type == PortalItemType.WebMap select item; // Loop through all sub-folders and get web map items, add them to the mapItems collection foreach (PortalFolder folder in myContent.Folders) { IEnumerable <PortalItem> folderItems = await portal.User.GetContentAsync(folder.FolderId); mapItems.Concat(from item in folderItems where item.Type == PortalItemType.WebMap select item); } } // Show the web map portal items in the list box MapListBox.ItemsSource = mapItems; }
private async void MyMapsClicked(object sender, Windows.UI.Xaml.RoutedEventArgs e) { // Get web map portal items in the current user's folder or from a keyword search IEnumerable <PortalItem> mapItems = null; ArcGISPortal portal; // If the list has already been populated, return if (MyMapsList.ItemsSource != null) { return; } // Call a sub that will force the user to log in to ArcGIS Online (if they haven't already) var loggedIn = await EnsureLoggedInAsync(); if (!loggedIn) { return; } // Connect to the portal (will connect using the provided credentials) portal = await ArcGISPortal.CreateAsync(new Uri(ArcGISOnlineUrl)); // Get the user's content (items in the root folder and a collection of sub-folders) PortalUserContent myContent = await portal.User.GetContentAsync(); // Get the web map items in the root folder mapItems = from item in myContent.Items where item.Type == PortalItemType.WebMap select item; // Loop through all sub-folders and get web map items, add them to the mapItems collection foreach (PortalFolder folder in myContent.Folders) { IEnumerable <PortalItem> folderItems = await portal.User.GetContentAsync(folder.FolderId); mapItems.Concat(from item in folderItems where item.Type == PortalItemType.WebMap select item); } // Show the web maps in the list box MyMapsList.ItemsSource = mapItems; // Make sure the flyout is shown MyMapsFlyout.ShowAt(sender as Windows.UI.Xaml.FrameworkElement); }
private async void MyMapsClicked(object sender, EventArgs e) { try { // Get web map portal items in the current user's folder IEnumerable <PortalItem> mapItems = null; // Call a sub that will force the user to log in to ArcGIS Online (if they haven't already) bool loggedIn = await EnsureLoggedInAsync(); if (!loggedIn) { return; } // Connect to the portal (will connect using the provided credentials) ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(ServerUrl)); // Get the user's content (items in the root folder and a collection of sub-folders) PortalUserContent myContent = await portal.User.GetContentAsync(); // Get the web map items in the root folder mapItems = from item in myContent.Items where item.Type == PortalItemType.WebMap select item; // Loop through all sub-folders and get web map items, add them to the mapItems collection foreach (PortalFolder folder in myContent.Folders) { IEnumerable <PortalItem> folderItems = await portal.User.GetContentAsync(folder.FolderId); mapItems = mapItems.Concat(from item in folderItems where item.Type == PortalItemType.WebMap select item); } // Show the map results ShowMapList(mapItems); } catch (Exception ex) { new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show(); } }
private async void GetMyMaps(object sender, EventArgs e) { try { // Call a sub that will force the user to log in to ArcGIS Online (if they haven't already) bool loggedIn = await EnsureLoggedInAsync(); if (!loggedIn) { return; } // Connect to the portal (will connect using the provided credentials) ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(ArcGISOnlineUrl)); // Get the user's content (items in the root folder and a collection of sub-folders) PortalUserContent myContent = await portal.User.GetContentAsync(); // Get the web map items in the root folder IEnumerable <PortalItem> mapItems = from item in myContent.Items where item.Type == PortalItemType.WebMap select item; // Loop through all sub-folders and get web map items, add them to the mapItems collection foreach (PortalFolder folder in myContent.Folders) { IEnumerable <PortalItem> folderItems = await portal.User.GetContentAsync(folder.FolderId); mapItems = mapItems.Concat(from item in folderItems where item.Type == PortalItemType.WebMap select item); } // Show the list of web maps MapsListView.ItemsSource = mapItems.ToList(); // Explicit ToList() needed to avoid Xamarin.Forms UWP ListView bug. MapsListView.IsVisible = true; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }