private async void Initialize()
        {
            // Apply an imagery basemap to the map.
            MyMapView.Map = new Map(Basemap.CreateDarkGrayCanvasVector());

            // Create the WMS Service.
            WmsService service = new WmsService(_wmsUrl);

            try
            {
                // Load the WMS Service.
                await service.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = service.ServiceInfo;

                // Get the list of layer infos.
                foreach (var layerInfo in info.LayerInfos)
                {
                    LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), _viewModelList);
                }

                // Update the map display based on the viewModel.
                UpdateMapDisplay(_viewModelList);

                // Update the list of layers.
                MyDisplayList.ItemsSource = _viewModelList;
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
        private async void Initialize()
        {
            // Apply an imagery basemap to the map
            _myMapView.Map = new Map(Basemap.CreateDarkGrayCanvasVector());

            // Create the WMS Service
            WmsService service = new WmsService(_wmsUrl);

            // Load the WMS Service
            await service.LoadAsync();

            // Get the service info (metadata) from the service.
            WmsServiceInfo info = service.ServiceInfo;

            // Get the list of layer infos.
            foreach (var layerInfo in info.LayerInfos)
            {
                LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), _viewModelList);
            }

            // Create an array adapter for the layer display
            ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, _viewModelList);

            // Apply the adapter
            _myDisplayList.Adapter = adapter;

            // Subscribe to selection change notifications
            _myDisplayList.ItemClick += _myDisplayList_ItemClick;

            // Update the map display based on the viewModel
            UpdateMapDisplay(_viewModelList);
        }
        private async void Initialize()
        {
            // Show dark gray canvas basemap.
            _myMapView.Map = new Map(Basemap.CreateDarkGrayCanvasVector());

            // Create the WMS Service.
            WmsService service = new WmsService(_wmsUrl);

            // Load the WMS Service.
            await service.LoadAsync();

            // Get the service info (metadata) from the service.
            WmsServiceInfo info = service.ServiceInfo;

            List <LayerDisplayVM> viewModelList = new List <LayerDisplayVM>();

            // Get the list of layer infos.
            foreach (var layerInfo in info.LayerInfos)
            {
                LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), viewModelList);
            }

            // Construct the layer list source.
            _layerListSource = new LayerListSource(viewModelList, this);

            // Set the source for the table view (layer list).
            _myDisplayList.Source = _layerListSource;

            // Force an update of the list display.
            _myDisplayList.ReloadData();
        }
Esempio n. 4
0
        /// <summary>
        /// Takes action once a new layer selection is made
        /// </summary>
        private void MyDisplayList_SelectionChanged(object sender, SelectedItemChangedEventArgs e)
        {
            // Clear existing selection
            foreach (LayerDisplayVM item in _viewModelList)
            {
                item.IsEnabled = false;
            }

            // Hold a reference to the selected item
            LayerDisplayVM selectedItem = e.SelectedItem as LayerDisplayVM;

            // Update the selection
            selectedItem.IsEnabled = true;

            // Update the map
            UpdateMapDisplay(_viewModelList);
        }
        /// <summary>
        /// Takes action once a new layer selection is made.
        /// </summary>
        private void MyDisplayList_SelectionChanged(object sender, SelectedItemChangedEventArgs e)
        {
            // Deselect all layers.
            foreach (LayerDisplayVM item in _viewModelList)
            {
                item.Select(false);
            }

            // Hold a reference to the selected item
            LayerDisplayVM selectedItem = (LayerDisplayVM)e.SelectedItem;

            // Update the selection
            selectedItem.Select();

            // Update the map
            UpdateMapDisplay(_viewModelList);
        }
Esempio n. 6
0
        /// <summary>
        /// This method gets a table view cell for the suggestion at the specified index
        /// </summary>
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            // Try to get a re-usable cell (this is for performance)
            UITableViewCell cell = tableView.DequeueReusableCell(CellId);

            // If there are no cells, create a new one
            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, CellId);
            }

            // Get the specific item to display
            LayerDisplayVM item = _viewModelList[indexPath.Row];

            // Set the text on the cell
            cell.TextLabel.Text = item.Title;

            // Return the cell
            return(cell);
        }
        public static void BuildLayerInfoList(LayerDisplayVM root, IList <LayerDisplayVM> result)
        {
            // Add the root node to the result list.
            result.Add(root);

            // Initialize the child collection for the root.
            root.Children = new List <LayerDisplayVM>();

            // Recursively add sublayers.
            foreach (WmsLayerInfo layer in root.Info.LayerInfos)
            {
                // Create the view model for the sublayer.
                LayerDisplayVM layerVM = new LayerDisplayVM(layer, root);

                // Add the sublayer to the root's sublayer collection.
                root.Children.Add(layerVM);

                // Recursively add children.
                BuildLayerInfoList(layerVM, result);
            }
        }
        private async void Initialize()
        {
            // Apply an imagery basemap to the map
            _myMapView.Map = new Map(BasemapStyle.ArcGISDarkGray);

            // Create the WMS Service
            WmsService service = new WmsService(_wmsUrl);

            try
            {
                // Load the WMS Service
                await service.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = service.ServiceInfo;

                // Get the list of layer infos.
                foreach (var layerInfo in info.LayerInfos)
                {
                    LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), _viewModelList);
                }

                // Create an array adapter for the layer display
                ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, _viewModelList);

                // Apply the adapter
                _myDisplayList.Adapter = adapter;

                // Subscribe to selection change notifications
                _myDisplayList.ItemClick += _myDisplayList_ItemClick;

                // Update the map display based on the viewModel
                UpdateMapDisplay(_viewModelList);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
        private async void Initialize()
        {
            // Show dark gray canvas basemap.
            _myMapView.Map = new Map(BasemapStyle.ArcGISDarkGray);

            // Create the WMS Service.
            WmsService service = new WmsService(_wmsUrl);

            try
            {
                // Load the WMS Service.
                await service.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = service.ServiceInfo;

                List <LayerDisplayVM> viewModelList = new List <LayerDisplayVM>();

                // Get the list of layer infos.
                foreach (var layerInfo in info.LayerInfos)
                {
                    LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), viewModelList);
                }

                // Construct the layer list source.
                _layerListSource = new LayerListSource(viewModelList, this);

                // Set the source for the table view (layer list).
                _layerList.Source = _layerListSource;

                // Force an update of the list display.
                _layerList.ReloadData();
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        /// <summary>
        /// This method gets a table view cell for the suggestion at the specified index.
        /// </summary>
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            // Try to get a re-usable cell (this is for performance).
            UITableViewCell cell = tableView.DequeueReusableCell(CellId);

            // If there are no cells, create a new one.
            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, CellId)
                {
                    BackgroundColor = UIColor.FromWhiteAlpha(0, 0f)
                };
                cell.TextLabel.TextColor = Owner.View.TintColor;
            }

            // Get the specific item to display.
            LayerDisplayVM item = ViewModelList[indexPath.Row];

            // Set the text on the cell.
            cell.TextLabel.Text = item.Name;

            // Return the cell.
            return(cell);
        }
 public LayerDisplayVM(WmsLayerInfo info, LayerDisplayVM parent)
 {
     Info   = info;
     Parent = parent;
 }