private void Initialize() { // Create new Map Map myMap = new Map(); // Create the uri for the tiled layer Uri tiledLayerUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer"); // Create a tiled layer using url ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri); tiledLayer.Name = "Tiled Layer"; // Add the tiled layer to map myMap.OperationalLayers.Add(tiledLayer); // Create the uri for the ArcGISMapImage layer var imageLayerUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"); // Create ArcGISMapImage layer using a url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri); imageLayer.Name = "Image Layer"; // Set the visible scale range for the image layer imageLayer.MinScale = 40000000; imageLayer.MaxScale = 2000000; // Add the image layer to map myMap.OperationalLayers.Add(imageLayer); //Create Uri for feature layer var featureLayerUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0"); //Create a feature layer using url FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri); myFeatureLayer.Name = "Feature Layer"; // Add the feature layer to map myMap.OperationalLayers.Add(myFeatureLayer); // Create a mappoint the map should zoom to MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator); // Set the initial viewpoint for map myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000); // Initialize the model list with unknown status for each layer foreach (Layer layer in myMap.OperationalLayers) { _layerStatusModels.Add(new LayerStatusModel(layer.Name, "Unknown")); } // Create the tableview source and pass the list of models to it _tableView.Source = new LayerViewStatusTableSource(_layerStatusModels); // Event for layer view state changed _myMapView.LayerViewStateChanged += OnLayerViewStateChanged; // Provide used Map to the MapView _myMapView.Map = myMap; }
private async void Initialize() { // Create new Map Map myMap = new Map(); // Create uri to the map image layer var serviceUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer"); // Create new image layer from the url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(serviceUri) { Name = "World Cities Population" }; // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(imageLayer); // Assign the map to the MapView MyMapView.Map = myMap; // Wait that the image layer is loaded and sublayer information is fetched await imageLayer.LoadAsync(); // Assign sublayers to the listview sublayerListView.ItemsSource = imageLayer.Sublayers; }
private async void Initialize() { // Define a challenge handler method for the AuthenticationManager // (this method handles getting credentials when a secured resource is encountered) AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateCredentialAsync); // Create the public layer and provide a name var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl)); publicLayer.Name = PublicLayerName; // Create the secured layer and provide a name var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl)); tokenSecuredLayer.Name = SecureLayerName; // Bind the layer to UI controls to show the load status PublicLayerStatusPanel.BindingContext = publicLayer; SecureLayerStatusPanel.BindingContext = tokenSecuredLayer; // Create a new map and add the layers var myMap = new Map(); myMap.OperationalLayers.Add(publicLayer); myMap.OperationalLayers.Add(tokenSecuredLayer); // Add the map to the map view MyMapView.Map = myMap; // Create the login UI (will display when the user accesses a secured resource) _loginPage = new LoginPage(); // Set up event handlers for when the user completes the login entry or cancels _loginPage.OnLoginInfoEntered += LoginInfoEntered; _loginPage.OnCanceled += LoginCanceled; }
private async void Initialize() { // Define a challenge handler method for the AuthenticationManager // (this method handles getting credentials when a secured resource is encountered) AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateKnownCredentials); // Create the public layer and provide a name var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl)); publicLayer.Name = PublicLayerName; // Create the secured layer and provide a name var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl)); tokenSecuredLayer.Name = SecureLayerName; // Bind the layer to UI controls to show the load status PublicLayerStatusPanel.BindingContext = publicLayer; SecureLayerStatusPanel.BindingContext = tokenSecuredLayer; // Create a new map and add the layers var myMap = new Map(); myMap.OperationalLayers.Add(publicLayer); myMap.OperationalLayers.Add(tokenSecuredLayer); // Add the map to the map view MyMapView.Map = myMap; }
private void Initialize() { // Create the public layer and provide a name var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl)); publicLayer.Name = PublicLayerName; // Set the data context for the public layer stack panel controls (to report name and load status) PublicLayerPanel.DataContext = publicLayer; // Create the secured layer and provide a name var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl)); tokenSecuredLayer.Name = SecureLayerName; // Set the data context for the secure layer stack panel controls (to report name and load status) SecureLayerPanel.DataContext = tokenSecuredLayer; // Create a new map and add the layers var myMap = new Map(); myMap.OperationalLayers.Add(publicLayer); myMap.OperationalLayers.Add(tokenSecuredLayer); var t = new TextBlock(); // Add the map to the map view MyMapView.Map = myMap; }
private void Initialize() { // Create new Map Map myMap = new Map(); // Create the uri for the tiled layer var tiledLayerUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer"); // Create a tiled layer using url ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri); tiledLayer.Name = "Tiled Layer"; // Add the tiled layer to map myMap.OperationalLayers.Add(tiledLayer); // Create the uri for the ArcGISMapImage layer var imageLayerUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"); // Create ArcGISMapImage layer using a url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri); imageLayer.Name = "Image Layer"; // Set the visible scale range for the image layer imageLayer.MinScale = 40000000; imageLayer.MaxScale = 2000000; // Add the image layer to map myMap.OperationalLayers.Add(imageLayer); // Create Uri for feature layer var featureLayerUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0"); // Create a feature layer using url FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri); myFeatureLayer.Name = "Feature Layer"; // Add the feature layer to map myMap.OperationalLayers.Add(myFeatureLayer); // Create a map point the map should zoom to MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator); // Set the initial viewpoint for map myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000); // Event for layer view state changed MyMapView.LayerViewStateChanged += OnLayerViewStateChanged; // Provide used Map to the MapView MyMapView.Map = myMap; }
public async override void ViewDidLoad() { base.ViewDidLoad(); // Create a new ArcGISMapImageLayer instance and pass a Url to the service var mapImageLayer = new ArcGISMapImageLayer( new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer")); // Await the load call for the layer. await mapImageLayer.LoadAsync(); // Create a new Map instance with the basemap Map myMap = new Map(SpatialReferences.Wgs84); myMap.Basemap = Basemap.CreateTopographic(); // Add the map image layer to the map's operational layers myMap.OperationalLayers.Add(mapImageLayer); // Create a new MapView control and provide its location coordinates on the frame. MapView myMapView = new MapView(); myMapView.Frame = new CoreGraphics.CGRect(0, 60, View.Bounds.Width, View.Bounds.Height - 40); // Assign the Map to the MapView myMapView.Map = myMap; // Create a button to show sublayers UIButton sublayersButton = new UIButton(UIButtonType.Custom); sublayersButton.Frame = new CoreGraphics.CGRect(0, myMapView.Bounds.Height, View.Bounds.Width, 40); sublayersButton.BackgroundColor = UIColor.White; sublayersButton.SetTitle("Sublayers", UIControlState.Normal); sublayersButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); // Create a new instance of the Sublayers Table View Controller. This View Controller // displays a table of sublayers with a switch for setting the layer visibility. SublayersTable sublayersTableView = new SublayersTable(); // When the sublayers button is clicked, load the Sublayers Table View Controller sublayersButton.TouchUpInside += (s, e) => { if (mapImageLayer.Sublayers.Count > 0) { sublayersTableView.mapImageLayer = mapImageLayer; this.NavigationController.PushViewController(sublayersTableView, true); } }; // Add the MapView and Sublayers button to the View View.AddSubviews(myMapView, sublayersButton); }
private void Initialize() { // Create new Map using spatial reference as world bonne (54024) Map myMap = new Map(SpatialReference.Create(54024)); // Adding a map image layer which can reproject itself to the map's spatial reference // Note: Some layer such as tiled layer cannot reproject and will fail to draw if their spatial // reference is not the same as the map's spatial reference ArcGISMapImageLayer operationalLayer = new ArcGISMapImageLayer(new Uri( "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer")); // Add operational layer to the Map myMap.OperationalLayers.Add(operationalLayer); // Assign the map to the MapView _myMapView.Map = myMap; }
private void Initialize() { // Create new Map Map myMap = new Map(); // Create uri to the map image layer var serviceUri = new Uri( "http://sampleserver5.arcgisonline.com/arcgis/rest/services/Elevation/WorldElevations/MapServer"); // Create new image layer from the url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(serviceUri); // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(imageLayer); // Assign the map to the MapView _myMapView.Map = myMap; }
private void Initialize() { // Create new Map Map myMap = new Map(); // Create uri to the map image layer var serviceUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer"); // Create new image layer from the url _imageLayer = new ArcGISMapImageLayer(serviceUri) { Name = "World Cities Population" }; // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(_imageLayer); // Assign the map to the MapView MyMapView.Map = myMap; }
private async void _localMapService_StatusChanged(object sender, StatusChangedEventArgs e) { // Add the shapefile layer to the map once the service finishes starting if (e.Status == LocalServerStatus.Started) { // Create the imagery layer ArcGISMapImageLayer imageryLayer = new ArcGISMapImageLayer(_localMapService.Url); // Subscribe to image layer load status change events // Only set up the sublayer renderer for the shapefile after the parent layer has finished loading imageryLayer.LoadStatusChanged += (q, ex) => { // Add the layer to the map once loaded if (ex.Status == Esri.ArcGISRuntime.LoadStatus.Loaded) { // Create a default symbol style SimpleLineSymbol _lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 3); // Apply the symbol style with a renderer _shapefileSublayer.Renderer = new SimpleRenderer(_lineSymbol); // Add the shapefile sublayer to the imagery layer imageryLayer.Sublayers.Add(_shapefileSublayer); } }; // Load the layer await imageryLayer.LoadAsync(); // Clear any existing layers MyMapView.Map.OperationalLayers.Clear(); // Add the image layer to the map MyMapView.Map.OperationalLayers.Add(imageryLayer); } }
private async void Initialize() { // Create a new map based on the streets base map. Map newMap = new Map(Basemap.CreateStreets()); // Assign the map to the MapView. MyMapView.Map = newMap; // Create an ArcGIS map image layer based on the Uri to that points to an ArcGIS Server map service that contains four Census sub-layers. // NOTE: sub-layer[0] = Census Block Points, sub-layer[1] = Census Block Group, sub-layer[3] = Counties, sub-layer[3] = States. _arcGISMapImageLayer = new ArcGISMapImageLayer(new System.Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer")); // Add the ArcGIS map image layer to the map's operation layers collection. newMap.OperationalLayers.Add(_arcGISMapImageLayer); // Load the ArcGIS map image layer. await _arcGISMapImageLayer.LoadAsync(); // Create an envelope that covers the continental US in the web Mercator spatial reference. Envelope continentalUSEnvelope = new Envelope(-14193469.5655232, 2509617.28647268, -7228772.04749191, 6737139.97573925, SpatialReferences.WebMercator); // Zoom the map to the extent of the envelope. await MyMapView.SetViewpointGeometryAsync(continentalUSEnvelope); }
private async void submitQuery(UIAlertAction obj) { // If the population value entered is not numeric, warn the user and exit. double populationNumber; if (!double.TryParse(_queryEntry.Text.Trim(), out populationNumber)) { UIAlertController alert = UIAlertController.Create("Invalid number", "Population value must be numeric.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); return; } // Get the USA map image layer (the first and only operational layer in the map). ArcGISMapImageLayer usaMapImageLayer = (ArcGISMapImageLayer)_myMapView.Map.OperationalLayers[0]; try { // Use a utility method on the map image layer to load all the sublayers and tables. await usaMapImageLayer.LoadTablesAndLayersAsync(); // Get the sublayers of interest (skip 'Highways' since it doesn't have the POP2000 field). ArcGISMapImageSublayer citiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[0]; ArcGISMapImageSublayer statesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[2]; ArcGISMapImageSublayer countiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[3]; // Get the service feature table for each of the sublayers. ServiceFeatureTable citiesTable = citiesSublayer.Table; ServiceFeatureTable statesTable = statesSublayer.Table; ServiceFeatureTable countiesTable = countiesSublayer.Table; // Create the query parameters that will find features in the current extent with a population greater than the value entered. QueryParameters populationQuery = new QueryParameters { WhereClause = "POP2000 > " + populationNumber, Geometry = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry }; // Query each of the sublayers with the query parameters. FeatureQueryResult citiesQueryResult = await citiesTable.QueryFeaturesAsync(populationQuery); FeatureQueryResult statesQueryResult = await statesTable.QueryFeaturesAsync(populationQuery); FeatureQueryResult countiesQueryResult = await countiesTable.QueryFeaturesAsync(populationQuery); // Display the selected cities in the graphics overlay. SimpleMarkerSymbol citySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 16); foreach (Feature city in citiesQueryResult) { Graphic cityGraphic = new Graphic(city.Geometry, citySymbol); _selectedFeaturesOverlay.Graphics.Add(cityGraphic); } // Display the selected counties in the graphics overlay. SimpleLineSymbol countyLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Cyan, 2); SimpleFillSymbol countySymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, Color.Cyan, countyLineSymbol); foreach (Feature county in countiesQueryResult) { Graphic countyGraphic = new Graphic(county.Geometry, countySymbol); _selectedFeaturesOverlay.Graphics.Add(countyGraphic); } // Display the selected states in the graphics overlay. SimpleLineSymbol stateLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.DarkCyan, 6); SimpleFillSymbol stateSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, Color.Cyan, stateLineSymbol); foreach (Feature state in statesQueryResult) { Graphic stateGraphic = new Graphic(state.Geometry, stateSymbol); _selectedFeaturesOverlay.Graphics.Add(stateGraphic); } } 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 /// 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
private void Initialize() { // Create new Map Map myMap = new Map(); // Create the uri for the tiled layer Uri tiledLayerUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer"); // Create a tiled layer using url ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri); tiledLayer.Name = "Tiled Layer"; // Add the tiled layer to map myMap.OperationalLayers.Add(tiledLayer); // Create the uri for the ArcGISMapImage layer var imageLayerUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"); // Create ArcGISMapImage layer using a url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri); imageLayer.Name = "Image Layer"; // Set the visible scale range for the image layer imageLayer.MinScale = 40000000; imageLayer.MaxScale = 2000000; // Add the image layer to map myMap.OperationalLayers.Add(imageLayer); //Create Uri for feature layer var featureLayerUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0"); //Create a feature layer using url FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri); myFeatureLayer.Name = "Feature Layer"; // Add the feature layer to map myMap.OperationalLayers.Add(myFeatureLayer); // Create a mappoint the map should zoom to MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator); // Set the initial viewpoint for map myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000); // Initialize the model list with unknown status for each layer foreach (Layer layer in myMap.OperationalLayers) { _layerStatusModels.Add(new LayerStatusModel(layer.Name, "Unknown")); } // Create the tableview source and pass the list of models to it _tableView.Source = new LayerViewStatusTableSource(_layerStatusModels); // Event for layer view state changed _myMapView.LayerViewStateChanged += OnLayerViewStateChanged; // Provide used Map to the MapView _myMapView.Map = myMap; }
private void AddOperationalLayers() { // Clear the operational layers from the map Map myMap = MyMapView.Map; myMap.OperationalLayers.Clear(); // Loop through the selected items in the operational layers list box foreach (var item in LayerListView.SelectedItems) { // Get the service uri for each selected item var layerInfo = (KeyValuePair<string, string>)item; var layerUri = new Uri(layerInfo.Value); // Create a new map image layer, set it 50% opaque, and add it to the map ArcGISMapImageLayer layer = new ArcGISMapImageLayer(layerUri); layer.Opacity = 0.5; myMap.OperationalLayers.Add(layer); } }
private async void QuerySublayers_Click(object sender, System.Windows.RoutedEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // If the population value entered is not numeric, warn the user and exit. double populationNumber = 0.0; if (!double.TryParse(PopulationTextBox.Text.Trim(), out populationNumber)) { MessageBox.Show("The population value must be numeric.", "Query error"); return; } // Get the USA map image layer (the first and only operational layer in the map). ArcGISMapImageLayer usaMapImageLayer = (ArcGISMapImageLayer)MyMapView.Map.OperationalLayers[0]; try { // Use a utility method on the map image layer to load all the sublayers and tables. await usaMapImageLayer.LoadTablesAndLayersAsync(); // Get the sublayers of interest (skip 'Highways' since it doesn't have the POP2000 field). ArcGISMapImageSublayer citiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[0]; ArcGISMapImageSublayer statesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[2]; ArcGISMapImageSublayer countiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[3]; // Get the service feature table for each of the sublayers. ServiceFeatureTable citiesTable = citiesSublayer.Table; ServiceFeatureTable statesTable = statesSublayer.Table; ServiceFeatureTable countiesTable = countiesSublayer.Table; // Create the query parameters that will find features in the current extent with a population greater than the value entered. QueryParameters populationQuery = new QueryParameters { WhereClause = "POP2000 > " + PopulationTextBox.Text, Geometry = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry }; // Query each of the sublayers with the query parameters. FeatureQueryResult citiesQueryResult = await citiesTable.QueryFeaturesAsync(populationQuery); FeatureQueryResult statesQueryResult = await statesTable.QueryFeaturesAsync(populationQuery); FeatureQueryResult countiesQueryResult = await countiesTable.QueryFeaturesAsync(populationQuery); // Display the selected cities in the graphics overlay. SimpleMarkerSymbol citySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 16); foreach (Feature city in citiesQueryResult) { Graphic cityGraphic = new Graphic(city.Geometry, citySymbol); _selectedFeaturesOverlay.Graphics.Add(cityGraphic); } // Display the selected counties in the graphics overlay. SimpleLineSymbol countyLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Cyan, 2); SimpleFillSymbol countySymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, Color.Cyan, countyLineSymbol); foreach (Feature county in countiesQueryResult) { Graphic countyGraphic = new Graphic(county.Geometry, countySymbol); _selectedFeaturesOverlay.Graphics.Add(countyGraphic); } // Display the selected states in the graphics overlay. SimpleLineSymbol stateLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.DarkCyan, 6); SimpleFillSymbol stateSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, Color.Cyan, stateLineSymbol); foreach (Feature state in statesQueryResult) { Graphic stateGraphic = new Graphic(state.Geometry, stateSymbol); _selectedFeaturesOverlay.Graphics.Add(stateGraphic); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }
} // 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
public void AddLayerFromUrl(string layerUrl) { ArcGISMapImageLayer layer = new ArcGISMapImageLayer(new Uri(layerUrl)); Map.OperationalLayers.Add(layer); }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // ¼ÓÔØoperationalLayers ͼ²ã if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; layers.Clear(); for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); string Content = $"ͼ²ã{LayerCount} £º {GrouplLayers_title}"; sceneView.Scene.OperationalLayers.Add(Scenelayer); layers.Add(new ItemLayer(Content)); //Label lab = new Label { Content = $"ͼ²ã{LayerCount} £º {GrouplLayers_title}" }; } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); string Content = $"ͼ²ã{LayerCount} £º {operational_title}"; layers.Add(new ItemLayer(Content)); //Label lab = new Label { Content = $"ͼ²ã{LayerCount} £º {operational_title}" }; } } if (layers.Count > 0) { Context context = this.BaseContext; ListLayerAdapter adapter = new ListLayerAdapter(layers, context); listLayer.Adapter = adapter; } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // ¼ÓÔص×ͼ baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // ¼ÓÔØ¸ß³Ì elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // ¼ÓÔØÊéÇ© slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; bks.Clear(); for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); double targetGeometry_x = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["x"]; double targetGeometry_y = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["y"]; double targetGeometry_z = (double)jo["presentation"]["slides"][j]["viewpoint"]["targetGeometry"] ["z"]; double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; int SRID = (int)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["spatialReference"]["latestWkid"]; MapPoint cmpt = new MapPoint(slidesx, slidesy, slidesz, SpatialReference.Create(SRID)); Camera camera = new Camera(cmpt, slides_heading, slides_tilt, 0); MapPoint mp = new MapPoint(targetGeometry_x, targetGeometry_y, targetGeometry_z, SpatialReference.Create(SRID)); Viewpoint vp = new Viewpoint(mp, camera); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); ItemBookMark itembk = new ItemBookMark(bkname, bkimage, bk); bks.Add(itembk); } if (bks.Count > 0) { Context context = this.BaseContext; ListBookAdapter adapter = new ListBookAdapter(bks, context); listBookMark.Adapter = adapter; } } double initCamera_x = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["x"]; double initCamera_y = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["y"]; double initCamera_z = (double)jo["initialState"]["viewpoint"]["camera"]["position"]["z"]; double initCamera_heading = (double)jo["initialState"]["viewpoint"]["camera"]["heading"]; double initCamera_tilt = (double)jo["initialState"]["viewpoint"]["camera"]["tilt"]; int initSRID = (int)jo["initialState"]["viewpoint"]["camera"]["position"]["spatialReference"]["latestWkid"]; MapPoint initcmpt = new MapPoint(initCamera_x, initCamera_y, initCamera_z, SpatialReference.Create(initSRID)); Camera initCamera = new Camera(initcmpt, initCamera_heading, initCamera_tilt, 0); await _sceneLeftView.SetViewpointCameraAsync(initCamera, TimeSpan.FromSeconds(10)); } catch (Exception ex) { } }
// When a comment is clicked, get the related feature (service request) and select it on the map. private async void CommentsListBox_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // Get the clicked record (ArcGISFeature) using the list position. If one is not found, return. ArcGISFeature selectedComment = _commentFeatures[e.Position] as ArcGISFeature; if (selectedComment == null) { return; } // Get the map image layer that contains the service request sublayer and the service request comments table. ArcGISMapImageLayer serviceRequestsMapImageLayer = _myMapView.Map.OperationalLayers[0] as ArcGISMapImageLayer; // Get the (non-spatial) table that contains the service request comments. ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0]; // Get the relationship that defines related service request features to features in the comments table (this is the first and only relationship). RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault(); // Create query parameters to get the related service request for features in the comments table. RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo) { ReturnGeometry = true }; // Query the comments table to get the related service request feature for the selected comment. IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams); // Get the first result. RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault(); // Get the first feature from the result. If it's null, warn the user and return. ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature; if (serviceRequestFeature == null) { // Report to the user that a related feature was not found, then return. AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); AlertDialog alert = alertBuilder.Create(); alert.SetMessage("Related feature not found."); alert.Show(); return; } // Load the related service request feature (so its geometry is available). await serviceRequestFeature.LoadAsync(); // Get the service request geometry (point). MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint; // Create a cyan marker symbol to display the related feature. Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Cyan, 14); // Create a graphic using the service request point and marker symbol. Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol); // Add the graphic to the graphics overlay and zoom the map view to its extent. _selectedFeaturesOverlay.Graphics.Add(requestGraphic); await _myMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000); }
private async void Initialize() { // Create a new Map with a vector streets basemap. Map myMap = new Map(Basemap.CreateStreetsVector()); // Create the URI to the Service Requests map service. Uri serviceRequestUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/MapServer"); // Create a new ArcGISMapImageLayer that uses the service URI. ArcGISMapImageLayer serviceRequestsMapImageLayer = new ArcGISMapImageLayer(serviceRequestUri); try { // Load all sublayers and tables contained by the map image layer. await serviceRequestsMapImageLayer.LoadTablesAndLayersAsync(); // Set the initial map extent to the extent of all service request features. Envelope requestsExtent = serviceRequestsMapImageLayer.FullExtent; myMap.InitialViewpoint = new Viewpoint(requestsExtent); // Add the layer to the map. myMap.OperationalLayers.Add(serviceRequestsMapImageLayer); // Get the service request comments table from the map image layer. ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0]; // Create query parameters to get all non-null service request comment records (features) from the table. QueryParameters queryToGetNonNullComments = new QueryParameters { WhereClause = "requestid <> '' AND comments <> ''" }; // Query the comments table to get the non-null records. FeatureQueryResult commentQueryResult = await commentsTable.QueryFeaturesAsync(queryToGetNonNullComments, QueryFeatureFields.LoadAll); // Show the records from the service request comments table in the UITableView control. foreach (ArcGISFeature commentFeature in commentQueryResult) { _serviceRequestComments.Add(commentFeature); } // Create the table view source that uses the list of features. _commentsTableSource = new ServiceRequestCommentsTableSource(_serviceRequestComments); // Assign the table view source to the table view control. _tableView.Source = _commentsTableSource; // Subscribe to event. _commentsTableSource.ServiceRequestCommentSelected += CommentsTableSource_ServiceRequestCommentSelected; // Create a graphics overlay to show selected features and add it to the map view. _selectedFeaturesOverlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(_selectedFeaturesOverlay); // Assign the map to the MapView. _myMapView.Map = myMap; // Reload the table view data to refresh the display. _tableView.ReloadData(); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Create new Map Map myMap = new Map(); //########### TILED LAYER // Create uri to the tiled service var tiledLayerUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer"); // Create new tiled layer from the url ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri); // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(tiledLayer); //########### //########### DINAMYC LAYER // Create uri to the map image layer var serviceUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"); // Create new image layer from the url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(serviceUri) { Name = "World Cities Population" }; // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(imageLayer); //########### //########### FEATURE LAYER // Create feature table using a url _featureTable = new ServiceFeatureTable(new Uri(_statesUrl)); // Create feature layer using this feature table _featureLayer = new FeatureLayer(_featureTable); // Set the Opacity of the Feature Layer _featureLayer.Opacity = 0.6; // Create a new renderer for the States Feature Layer SimpleLineSymbol lineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, Colors.Black, 1); SimpleFillSymbol fillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, Colors.Yellow, lineSymbol); // Set States feature layer renderer _featureLayer.Renderer = new SimpleRenderer(fillSymbol); // Add feature layer to the map myMap.OperationalLayers.Add(_featureLayer); //########### // Assign the map to the MapView MyMapView.Map = myMap; // Wait that the image layer is loaded and sublayer information is fetched await imageLayer.LoadAsync(); // Assign sublayers to the listview sublayerListView.ItemsSource = imageLayer.Sublayers; }
private void Initialize() { // Create a spatial reference that's suitable for creating planar buffers in north central Texas (State Plane). SpatialReference statePlaneNorthCentralTexas = new SpatialReference(32038); // Define a polygon that represents the valid area of use for the spatial reference. // This information is available at https://developers.arcgis.com/net/latest/wpf/guide/pdf/projected_coordinate_systems_rt100_3_0.pdf List <MapPoint> spatialReferenceExtentCoords = new List <MapPoint> { new MapPoint(-103.070, 31.720, SpatialReferences.Wgs84), new MapPoint(-103.070, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.000, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.00, 31.720, SpatialReferences.Wgs84) }; _spatialReferenceArea = new Polygon(spatialReferenceExtentCoords); _spatialReferenceArea = (Polygon)GeometryEngine.Project(_spatialReferenceArea, statePlaneNorthCentralTexas); // Create a map that uses the North Central Texas state plane spatial reference. Map bufferMap = new Map(statePlaneNorthCentralTexas); // Add some base layers (counties, cities, and highways). Uri usaLayerSource = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer"); ArcGISMapImageLayer usaLayer = new ArcGISMapImageLayer(usaLayerSource); bufferMap.Basemap.BaseLayers.Add(usaLayer); // Use a new EnvelopeBuilder to expand the spatial reference extent 120%. EnvelopeBuilder envBuilder = new EnvelopeBuilder(_spatialReferenceArea.Extent); envBuilder.Expand(1.2); // Set the map's initial extent to the expanded envelope. Envelope startingEnvelope = envBuilder.ToGeometry(); bufferMap.InitialViewpoint = new Viewpoint(startingEnvelope); // Assign the map to the MapView. MyMapView.Map = bufferMap; // Create a graphics overlay to show the buffer polygon graphics. GraphicsOverlay bufferGraphicsOverlay = new GraphicsOverlay { // Give the overlay an ID so it can be found later. Id = "buffers" }; // Create a graphic to show the spatial reference's valid extent (envelope) with a dashed red line. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Red, 5); Graphic spatialReferenceExtentGraphic = new Graphic(_spatialReferenceArea, lineSymbol); // Add the graphic to a new overlay. GraphicsOverlay spatialReferenceGraphicsOverlay = new GraphicsOverlay(); spatialReferenceGraphicsOverlay.Graphics.Add(spatialReferenceExtentGraphic); // Add the graphics overlays to the MapView. MyMapView.GraphicsOverlays.Add(bufferGraphicsOverlay); MyMapView.GraphicsOverlays.Add(spatialReferenceGraphicsOverlay); // Wire up the MapView's GeoViewTapped event handler. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; }
private void Initialize() { // Define a challenge handler method for the AuthenticationManager // (this method handles getting credentials when a secured resource is encountered) AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateCredentialAsync); // Create the public layer and provide a name var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl)); publicLayer.Name = PublicLayerName; // Create the secured layer and provide a name var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl)); tokenSecuredLayer.Name = SecureLayerName; // Track the load status of each layer with a LoadStatusChangedEvent handler publicLayer.LoadStatusChanged += LayerLoadStatusChanged; tokenSecuredLayer.LoadStatusChanged += LayerLoadStatusChanged; // Create a new map and add the layers var myMap = new Map(); myMap.OperationalLayers.Add(publicLayer); myMap.OperationalLayers.Add(tokenSecuredLayer); // Add the map to the map view _myMapView.Map = myMap; }
// Handle a new selected comment record in the table view. private async void CommentsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // Get the selected comment feature. If there is no selection, return. ArcGISFeature selectedComment = e.AddedItems[0] as ArcGISFeature; if (selectedComment == null) { return; } // Get the map image layer that contains the service request sublayer and the service request comments table. ArcGISMapImageLayer serviceRequestsMapImageLayer = (ArcGISMapImageLayer)MyMapView.Map.OperationalLayers[0]; // Get the (non-spatial) table that contains the service request comments. ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0]; // Get the relationship that defines related service request features for features in the comments table (this is the first and only relationship). RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault(); // Create query parameters to get the related service request for features in the comments table. RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo) { ReturnGeometry = true }; try { // Query the comments table to get the related service request feature for the selected comment. IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams); // Get the first result. RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault(); // Get the first feature from the result. If it's null, warn the user and return. ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature; if (serviceRequestFeature == null) { MessageBox.Show("Related feature not found.", "No Feature"); return; } // Load the related service request feature (so its geometry is available). await serviceRequestFeature.LoadAsync(); // Get the service request geometry (point). MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint; // Create a cyan marker symbol to display the related feature. Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Cyan, 14); // Create a graphic using the service request point and marker symbol. Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol); // Add the graphic to the graphics overlay and zoom the map view to its extent. _selectedFeaturesOverlay.Graphics.Add(requestGraphic); await MyMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // 加载operationalLayers 图层 if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {GrouplLayers_title}" }; //this.listLayer.Items.Add(lab); } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {operational_title}" }; //this.listLayer.Items.Add(lab); } } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // 加载底图 baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // 加载高程 elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // 加载书签 slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); Viewpoint vp = Viewpoint.FromJson(sttt); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); // Camera ca = new Camera(); // Label lab = new Label { Content = $"书签{bookMarkCount} : {bkname}" }; //lab.Tag = vp; //lab.MouseDown += Lab_MouseDown; // this.listbookMark.Items.Add(lab); //double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; //double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; //double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; //double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; //double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; } } string initialState = JsonConvert.SerializeObject(jo["initialState"]["viewpoint"]); Viewpoint initialViewpoint = Viewpoint.FromJson(initialState); await sceneView.SetViewpointAsync(initialViewpoint, TimeSpan.FromSeconds(10)); } catch { } }