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); } // 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); 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. LayerTreeView.ItemsSource = _viewModelList.Take(1); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
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 IReadOnlyList <WmsLayerInfo> topLevelLayers = info.LayerInfos; // Recursively build up a list of all the layers in the service and get their IDs as a flat list List <WmsLayerInfo> expandedList = new List <WmsLayerInfo>(); BuildLayerInfoList(topLevelLayers, expandedList); // Build the ViewModel from the expanded list of layer infos foreach (WmsLayerInfo layerInfo in expandedList) { // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of the ArcGIS Runtime _viewModelList.Add(new LayerDisplayVM(layerInfo)); } // Update the map display based on the viewModel UpdateMapDisplay(_viewModelList); // Update the list of layers MyDisplayList.ItemsSource = _viewModelList; }
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(); }
private async void Initialize() { // Apply an imagery basemap to the map _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // 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 IReadOnlyList <WmsLayerInfo> topLevelLayers = info.LayerInfos; // Recursively build up a list of all the layers in the service and get their IDs as a flat list List <WmsLayerInfo> expandedList = new List <WmsLayerInfo>(); BuildLayerInfoList(topLevelLayers, expandedList); // Build the ViewModel from the expanded list of layer infos foreach (WmsLayerInfo layerInfo in expandedList) { // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of the ArcGIS Runtime _viewModelList.Add(new LayerDisplayVM(layerInfo)); } // 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() { // 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 IReadOnlyList <WmsLayerInfo> topLevelLayers = info.LayerInfos; // Recursively build up a list of all the layers in the service and get their IDs as a flat list List <WmsLayerInfo> expandedList = new List <WmsLayerInfo>(); BuildLayerInfoList(topLevelLayers, expandedList); List <LayerDisplayVM> displayList = new List <LayerDisplayVM>(); // Build the ViewModel from the expanded list of layer infos foreach (WmsLayerInfo layerInfo in expandedList) { // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of the ArcGIS Runtime displayList.Add(new LayerDisplayVM(layerInfo)); } // Construct the layer list source _layerListSource = new LayerListSource(displayList, this); // Set the source for the table view (layer list) _myDisplayList.Source = _layerListSource; // Force an update of the list display _myDisplayList.ReloadData(); }
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(); } }
} // end MainWindow /// <summary> /// Open WMS service and store the list of imagery /// preserving hierarchy, if any /// Source: Runtime wms Service catalog /// MOD - pass in serviceurl /// </summary> private async void InitializeWMSLayer_VM() { // Initialize the display with a basemap // Reset Map projection if applicable Map myMap = new Map(SpatialReference.Create(4326)); baseImageLayer = new ArcGISMapImageLayer(new Uri( "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer")); // Add baseImageLayer to the Map myMap.OperationalLayers.Add(baseImageLayer); // Assign the map to the MapView BasemapView.Map = myMap; // Create the WMS Service Load data from the URI // Create WMS Service service with default uri serviceURI = new Uri(wmsUriStartup.capableUri); serviceWMS = new WmsService(serviceURI); // If service can load, initialize the app try { // Load the WMS Service. await serviceWMS.LoadAsync(); // Get the service info (metadata) from the service. WmsServiceInfo info = serviceWMS.ServiceInfo; // Process info to get information for all the layers // for the given serviceUri // LayerInfos gets a list of sublayers for a given layer IList <LayerInfoVM> temp = new List <LayerInfoVM>(); foreach (WmsLayerInfo layerInfo in info.LayerInfos) { LayerInfoVM.BuildLayerInfoList(new LayerInfoVM(layerInfo, null, false), _layerInfoOC); } // NASA GIBS Specific #region NASA string epsg = wmsUriStartup.EPSG.Substring(0, 4) + ":" + wmsUriStartup.EPSG.Substring(4, 4); ProductLabel.Content = "NASA GIBS for EODIS: " + wmsUriStartup.latency.ToUpper() + " - " + epsg.ToUpper(); Sort_NASA_GIBS(_layerInfoOC, out temp); _layerInfoOC.Clear(); foreach (LayerInfoVM layerInfo in temp) { _layerInfoOC.Add(layerInfo); } #endregion NASA // Update the map display based on the viewModel. UpdateViewModel(_layerInfoOC); // Update Product List //ProductTreeView.ItemsSource = _layerInfoOC; ProductList.ItemsSource = _layerInfoOC; } // end try catch (Exception e) { MessageBox.Show(e.ToString(), "WMS SERVER LOAD ERROR"); } } // end InitializeWMSLayer_VM
} // end MainWindow /// <summary> /// Open WMS service and store the list of imagery /// perserving heirarchy, if any /// Source: Runtime wms Service catalog /// MOD - pass in serviceurl /// </summary> private async void InitializeWMSLayer_VM() { // Initialize the display with a basemap // BasemapView is UI esri mapview name in XAML // Reset Map projection if applicable Map myMap = new Map(SpatialReference.Create(4326)); baseImageLayer = new ArcGISMapImageLayer(new Uri( "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer")); // Add baseImageLayer to the Map myMap.OperationalLayers.Add(baseImageLayer); // Assign the map to the MapView BasemapView.Map = myMap; // Create the WMS Service Load data from the URI // Create WMS Service service with default uri serviceURI = new Uri(wmsUriStartup.capableUri); serviceWMS = new WmsService(serviceURI); // If service can load, initialize the app try { // Load the WMS Service. await serviceWMS.LoadAsync(); // Get the service info (metadata) from the service. WmsServiceInfo info = serviceWMS.ServiceInfo; // Process info to get information for all the layers // for the given serviceUri // LayerInfos gets a list of sublayers for a given layer foreach (var layerInfo in info.LayerInfos) { LayerInfoVM.BuildLayerInfoList(new LayerInfoVM(layerInfo, null, false), _layerInfoOC); } // Sort Layers // This sorts list but list does not get passed to Itemsource /* * List<WmsLayerInfo> sortedWmsInfo = new List<WmsLayerInfo>(); * ObservableCollection<LayerInfoVM> SortedList = new ObservableCollection<LayerInfoVM>( _layerInfoOC.OrderBy(o => o.Info.Title).ToList()) * _layerInfoOC = new ObservableCollection<LayerInfoVM>(SortedList); * foreach (LayerInfoVM layerInfo in _layerInfoOC) * Debug.WriteLine(layerInfo.Info.Title + " " + layerInfo.Info.Name); * Debug.WriteLine("Counts: " + _layerInfoOC.Count + " " + SortedList.Count); */ // Update the map display based on the viewModel. UpdateViewModel(_layerInfoOC); // Update UI element ProductLabel.Content = "NASA GIBS - " + wmsUriStartup.EPSG + " - " + wmsUriStartup.latency; ProductTreeView.ItemsSource = _layerInfoOC.Take(1); } // end try catch (Exception e) { MessageBox.Show(e.ToString(), "WMS SERVER LOAD ERROR"); } } // end InitializeWMSLayer_VM