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() { // Create a map with an initial viewpoint. Map myMap = new Map(Basemap.CreateTopographic()); myMap.InitialViewpoint = new Viewpoint(new MapPoint(-10977012.785807, 4514257.550369, SpatialReference.Create(3857)), 68015210); _myMapView.Map = myMap; try { // Add a map image layer to the map after turning off two sublayers. ArcGISMapImageLayer cityLayer = new ArcGISMapImageLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer")); await cityLayer.LoadAsync(); cityLayer.Sublayers[1].IsVisible = false; cityLayer.Sublayers[2].IsVisible = false; myMap.OperationalLayers.Add(cityLayer); // Add a feature layer to the map. FeatureLayer damageLayer = new FeatureLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0")); myMap.OperationalLayers.Add(damageLayer); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void AddOrRemoveLayer(string layerName) { // See if the layer already exists. ArcGISMapImageLayer layer = _myMapView.Map.OperationalLayers.FirstOrDefault(l => l.Name == layerName) as ArcGISMapImageLayer; // If the layer is in the map, remove it. if (layer != null) { _myMapView.Map.OperationalLayers.Remove(layer); } else { // Get the URL for this layer. string layerUrl = _operationalLayerUrls[layerName]; Uri layerUri = new Uri(layerUrl); // Create a new map image layer. layer = new ArcGISMapImageLayer(layerUri) { Name = layerName }; await layer.LoadAsync(); // Set it 50% opaque, and add it to the map. layer.Opacity = 0.5; _myMapView.Map.OperationalLayers.Add(layer); } }
private async void Initialize() { // Create a new Map instance with the basemap. Map map = new Map(SpatialReferences.Wgs84) { Basemap = Basemap.CreateTopographic() }; // Create a new ArcGISMapImageLayer instance and pass a URL to the service. _mapImageLayer = new ArcGISMapImageLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer")); // Assign the Map to the MapView. _myMapView.Map = map; // 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. _sublayersTableView = new SublayersTable(); try { // Await the load call for the layer. await _mapImageLayer.LoadAsync(); // Add the map image layer to the map's operational layers. map.OperationalLayers.Add(_mapImageLayer); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Create new Map with basemap // Create new Map Map myMap = new Map(Basemap.CreateOpenStreetMap()); // Create uri to the map image layer MyMapView.Map = myMap; // Create a new WMS layer displaying the specified layers from the service _wmsLayer = new ArcGISMapImageLayer(_wmsUrl); try { // Load the layer await _wmsLayer.LoadAsync(); //myMap.Basemap.BaseLayers.Add(_wmsLayer); // Add the layer to the map MyMapView.Map.OperationalLayers.Add(_wmsLayer); // Zoom to the layer's extent MyMapView.SetViewpoint(new Viewpoint(_wmsLayer.FullExtent)); // Subscribe to tap events - starting point for feature identification MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; } catch (Exception e) { // await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void OnSublayersClicked(object sender, EventArgs e) { // Make sure that layer and it's sublayers are loaded // If layer is already loaded, this returns directly await _imageLayer.LoadAsync(); var sublayersButton = sender as Button; // Create menu to change sublayer visibility var sublayersMenu = new PopupMenu(this, sublayersButton); sublayersMenu.MenuItemClick += OnSublayersMenuItemClicked; // Create menu options foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { sublayersMenu.Menu.Add(sublayer.Name); } // Set values to the menu items for (int i = 0; i < sublayersMenu.Menu.Size(); i++) { var menuItem = sublayersMenu.Menu.GetItem(i); // Set menu item to contain checkbox menuItem.SetCheckable(true); // Set default value menuItem.SetChecked(_imageLayer.Sublayers[i].IsVisible); } // Show menu in the view sublayersMenu.Show(); }
private async void MyMapView_Loaded(object sender, RoutedEventArgs e) { Map myMap = new Map(); myMap.Basemap = Basemap.CreateStreets(); MyMapView.Map = myMap; await MyMapView.SetViewpointGeometryAsync(new Envelope(-78.691528, 35.799884, -78.601835, 35.760055, SpatialReferences.Wgs84)); ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(new Uri(imageLayerUri)); await imageLayer.LoadAsync(); myMap.OperationalLayers.Add(imageLayer); for (int i = 0; i < imageLayer.Sublayers.Count; i++) { var legendLayer = imageLayer.SublayerContents[i]; legendLayer.ShowInLegend = true; var layerLegendInfo = await legendLayer.GetLegendInfosAsync(); foreach (var l in layerLegendInfo.ToList()) { legendTree.Items.Add(l); } } }
private async void Initialize() { // 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 map = new Map(SpatialReferences.Wgs84) { Basemap = Basemap.CreateTopographic() }; // Add the map image layer to the map's operational layers. map.OperationalLayers.Add(mapImageLayer); // Assign the Map to the MapView. _myMapView.Map = map; // 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 Sublayer Table View Controller. _sublayersButton.TouchUpInside += (s, e) => { if (mapImageLayer.Sublayers.Count > 0) { sublayersTableView.MapImageLayer = mapImageLayer; NavigationController.PushViewController(sublayersTableView, true); } }; }
private async void Initialize() { // Create new Map Map myMap = new Map(); // Create uri to the map image layer Uri 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 _localMapService_StatusChanged(object sender, StatusChangedEventArgs e) { // Return if the service hasn't started yet if (e.Status != LocalServerStatus.Started) { return; } // 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 Raster 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) { // Add the Raster sublayer to the imagery layer imageryLayer.Sublayers.Add(_rasterSublayer); } }; // 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); }
async void LoadMap() { Map myMap = new Map(Basemap.CreateImagery()); // Create uri to the map image layer //var serviceUri = new Uri( // "http://182.253.238.238:6080/arcgis/rest/services/Penutup_Lahan/MapServer"); var serviceUri = new Uri( "http://182.253.238.238:6080/arcgis/rest/services/Penutup_Lahan_BW/MapServer"); // Create new image layer from the url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(serviceUri); await imageLayer.LoadAsync(); // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(imageLayer); // Assign the map to the MapView MyMapView.Map = myMap; await MyMapView.SetViewpointGeometryAsync(imageLayer.FullExtent); }
private async void Initialize() { // Create a map with an initial viewpoint. Map myMap = new Map(Basemap.CreateTopographic()); myMap.InitialViewpoint = new Viewpoint(new MapPoint(-10977012.785807, 4514257.550369, SpatialReference.Create(3857)), 68015210); MyMapView.Map = myMap; try { // Add a map image layer to the map after turning off two sublayers. ArcGISMapImageLayer cityLayer = new ArcGISMapImageLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer")); await cityLayer.LoadAsync(); cityLayer.Sublayers[1].IsVisible = false; cityLayer.Sublayers[2].IsVisible = false; myMap.OperationalLayers.Add(cityLayer); // Add a feature layer to the map. FeatureLayer damageLayer = new FeatureLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0")); myMap.OperationalLayers.Add(damageLayer); // Listen for taps/clicks to start the identify operation. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; } catch (Exception e) { await new MessageDialog(e.ToString(), "Error").ShowAsync(); } }
private async void OnSublayersClicked(object sender, EventArgs e) { try { // Make sure that layer and it's sublayers are loaded // If layer is already loaded, this returns directly await _imageLayer.LoadAsync(); // Create layout for sublayers page // Create root layout StackLayout layout = new StackLayout(); // Create list for layers TableView sublayersTableView = new TableView(); // Create section for basemaps sublayers TableSection sublayersSection = new TableSection(_imageLayer.Name); // Create cells for each of the sublayers foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { // Using switch cells that provides on/off functionality SwitchCell cell = new SwitchCell() { Text = sublayer.Name, On = sublayer.IsVisible }; // Hook into the On/Off changed event cell.OnChanged += OnCellOnOffChanged; // Add cell into the table view sublayersSection.Add(cell); } // Add section to the table view sublayersTableView.Root.Add(sublayersSection); // Add table to the root layout layout.Children.Add(sublayersTableView); // Create internal page for the navigation page ContentPage sublayersPage = new ContentPage() { Content = layout, Title = "Sublayers" }; // Navigate to the sublayers page await Navigation.PushAsync(sublayersPage); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); try { // LocalServer must not be running when setting the data path. if (LocalServer.Instance.Status == LocalServerStatus.Started) { await LocalServer.Instance.StopAsync(); } // Set the local data path - must be done before starting. On most systems, this will be C:\EsriSamples\AppData. // This path should be kept short to avoid Windows path length limitations. string tempDataPathRoot = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.Windows)).FullName; string tempDataPath = Path.Combine(tempDataPathRoot, "EsriSamples", "AppData"); Directory.CreateDirectory(tempDataPath); // CreateDirectory won't overwrite if it already exists. LocalServer.Instance.AppDataPath = tempDataPath; // Start the local server instance await LocalServer.Instance.StartAsync(); // Get the path to the map package that will be served string datapath = GetDataPath(); // Create the Map Service from the data _localMapService = new LocalMapService(datapath); // Start the feature service await _localMapService.StartAsync(); // Get the url to the map service Uri myServiceUri = _localMapService.Url; // Create the layer from the url ArcGISMapImageLayer myImageLayer = new ArcGISMapImageLayer(myServiceUri); // Add the layer to the map MyMapView.Map.OperationalLayers.Add(myImageLayer); // Wait for the layer to load await myImageLayer.LoadAsync(); // Set the viewpoint on the map to show the data MyMapView.SetViewpoint(new Viewpoint(myImageLayer.FullExtent)); } catch (Exception ex) { var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); var dlg = new MessageDialog2($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); _ = dlg.ShowAsync(); } }
partial void AddLayer_TouchUpInside(UIButton sender) { _serviceURL = InputServiceURL.Text; if (_serviceURL.Length <= 4) { //Create Alert var okAlertController = UIAlertController.Create("No URL Input", "Please type in a URL in the text box.", UIAlertControllerStyle.Alert); //Add Action okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); // Present Alert PresentViewController(okAlertController, true, null); } else { if (_serviceURL.Substring(0, 4) != "http") { //Create Alert var okAlertController = UIAlertController.Create("Invalid URL", "Please input a valid URL", UIAlertControllerStyle.Alert); //Add Action okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); // Present Alert PresentViewController(okAlertController, true, null); } else { Uri serviceURI = new Uri(_serviceURL); if (_serviceURL.Contains("MapServer")) { ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(serviceURI); mapImageLayer.LoadAsync(); //_extent = mapImageLayer.FullExtent; _mapView.Map.OperationalLayers.Add(mapImageLayer); } else if (_serviceURL.Contains("FeatureServer")) { FeatureLayer featurelayer = new FeatureLayer(serviceURI); featurelayer.LoadAsync(); //_extent = featurelayer.FullExtent; _mapView.Map.OperationalLayers.Add(featurelayer); } else { //Create Alert var okAlertController = UIAlertController.Create("Invalid Service Type", "Please input a valid map service or feature service.", UIAlertControllerStyle.Alert); //Add Action okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); // Present Alert PresentViewController(okAlertController, true, null); } //_mapView.SetViewpointGeometryAsync(_extent); } } }
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("http://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 async void OnSublayersButtonClicked(object sender, RoutedEventArgs e) { try { // Make sure that layer and it's sublayers are loaded. // If layer is already loaded, this returns directly. await _imageLayer.LoadAsync(); ContentDialog dialog = new ContentDialog() { Title = "Sublayers", FullSizeDesired = true }; // Create list for layers. ListView sublayersListView = new ListView(); // Create cells for each of the sublayers. foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { // Generate a toggle that provides on/off functionality. ToggleSwitch toggle = new ToggleSwitch() { Header = sublayer.Name, IsOn = sublayer.IsVisible, Margin = new Thickness(5) }; // Hook into the On/Off changed event. toggle.Toggled += OnSublayerToggled; // Add cell into the table view. sublayersListView.Items.Add(toggle); } // Set listview to the dialog. dialog.Content = sublayersListView; // Add a close button for the dialog. dialog.PrimaryButtonText = "Close"; dialog.PrimaryButtonClick += (s, a) => dialog.Hide(); // Show dialog as a full screen overlay. await dialog.ShowAsync(); } catch (Exception ex) { await new MessageDialog(ex.ToString(), "Error").ShowAsync(); } }
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 async void GpJobOnJobChanged(object o, EventArgs eventArgs) { // Show message if job failed if (_gpJob.Status == JobStatus.Failed) { MessageBox.Show("Job Failed"); return; } ; // Return if not succeeded if (_gpJob.Status != JobStatus.Succeeded) { return; } // Get the URL to the map service string gpServiceResultUrl = _gpService.Url.ToString(); // Get the URL segment for the specific job results string jobSegment = "MapServer/jobs/" + _gpJob.ServerJobId; // Update the URL to point to the specific job from the service gpServiceResultUrl = gpServiceResultUrl.Replace("GPServer", jobSegment); // Create a map image layer to show the results ArcGISMapImageLayer myMapImageLayer = new ArcGISMapImageLayer(new Uri(gpServiceResultUrl)); // Load the layer await myMapImageLayer.LoadAsync(); // This is needed because the event comes from outside of the UI thread Dispatcher.Invoke(() => { // Add the layer to the map MyMapView.Map.OperationalLayers.Add(myMapImageLayer); // Hide the progress bar MyLoadingIndicator.Visibility = Visibility.Collapsed; // Disable the generate button MyUpdateContourButton.IsEnabled = false; // Enable the reset button MyResetButton.IsEnabled = true; }); }
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, Color.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); } }; try { // 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); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } } }
private async void _localMapService_StatusChanged(object sender, StatusChangedEventArgs e) { // Load a MapImageLayer from the service once it has started if (e.Status == LocalServerStatus.Started) { // Get the url to the map service Uri myServiceUri = _localMapService.Url; // Create the layer from the url ArcGISMapImageLayer myImageLayer = new ArcGISMapImageLayer(myServiceUri); // Add the layer to the map MyMapView.Map.OperationalLayers.Add(myImageLayer); // Wait for the layer to load await myImageLayer.LoadAsync(); // Set the viewpoint on the map to show the data MyMapView.SetViewpoint(new Viewpoint(myImageLayer.FullExtent)); } }
private async void OnSublayersClicked(object sender, EventArgs e) { try { // Make sure that layer and it's sublayers are loaded // If layer is already loaded, this returns directly await _imageLayer.LoadAsync(); Button sublayersButton = (Button)sender; // Create menu to change sublayer visibility PopupMenu sublayersMenu = new PopupMenu(this, sublayersButton); sublayersMenu.MenuItemClick += OnSublayersMenuItemClicked; // Create menu options foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { sublayersMenu.Menu.Add(sublayer.Name); } // Set values to the menu items for (int i = 0; i < sublayersMenu.Menu.Size(); i++) { IMenuItem menuItem = sublayersMenu.Menu.GetItem(i); // Set menu item to contain checkbox menuItem.SetCheckable(true); // Set default value menuItem.SetChecked(_imageLayer.Sublayers[i].IsVisible); } // Show menu in the view sublayersMenu.Show(); } catch (Exception ex) { new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show(); } }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); try { // Start the local server instance await LocalServer.Instance.StartAsync(); // Get the path to the map package that will be served string datapath = GetDataPath(); // Create the Map Service from the data _localMapService = new LocalMapService(datapath); // Start the feature service await _localMapService.StartAsync(); // Get the url to the map service Uri myServiceUri = _localMapService.Url; // Create the layer from the url ArcGISMapImageLayer myImageLayer = new ArcGISMapImageLayer(myServiceUri); // Add the layer to the map MyMapView.Map.OperationalLayers.Add(myImageLayer); // Wait for the layer to load await myImageLayer.LoadAsync(); // Set the viewpoint on the map to show the data MyMapView.SetViewpoint(new Viewpoint(myImageLayer.FullExtent)); } catch (Exception ex) { MessageBox.Show(string.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md or metadata.json. Message: {0}", ex.Message), "Local Server failed to start"); } }
private async void OnSublayersButtonClicked(object sender, RoutedEventArgs e) { // Make sure that layer and it's sublayers are loaded // If layer is already loaded, this returns directly await _imageLayer.LoadAsync(); var dialog = new ContentDialog() { Title = "Sublayers", FullSizeDesired = true }; // Create list for layers var sublayersListView = new ListView(); // Create cells for each of the sublayers foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { // Using a toggle that provides on/off functionality var toggle = new ToggleSwitch() { Header = sublayer.Name, IsOn = sublayer.IsVisible, Margin = new Thickness(5) }; // Hook into the On/Off changed event toggle.Toggled += OnSublayerToggled; // Add cell into the table view sublayersListView.Items.Add(toggle); } // Set listview to the dialog dialog.Content = sublayersListView; // Show dialog as a full screen overlay. await dialog.ShowAsync(); }
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("http://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 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; }