Beispiel #1
0
        private void OnMapSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // When a web map is selected, update the map in the map view
            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                // Make sure a portal item is selected
                var selectedMap = e.AddedItems[0] as PortalItem;
                if (selectedMap == null)
                {
                    return;
                }

                // Create a new map and display it
                var webMap = new Map(selectedMap);

                // Handle change in the load status (to report load errors)
                webMap.LoadStatusChanged += WebMapLoadStatusChanged;

                MyMapView.Map = webMap;
            }

            // Hide the flyouts
            SearchMapsFlyout.Hide();
            MyMapsFlyout.Hide();

            // Unselect the map item
            var list = sender as ListView;

            list.SelectedItem = null;
        }
Beispiel #2
0
        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);
        }