private void OnVectorLayersChooserSelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedVectorLayer = e.AddedItems[0].ToString(); switch (selectedVectorLayer) { case "Dark gray": _vectorTiledLayerUrl = _darkGrayUrl; break; case "Streets": _vectorTiledLayerUrl = _streetUrl; break; case "Night": _vectorTiledLayerUrl = _nightUrl; break; case "Navigation": _vectorTiledLayerUrl = _navigationUrl; break; default: break; } // Create a new ArcGISVectorTiledLayer with the Url Selected by the user _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // // Create new Map with basemap and assigning to the Mapviews Map MyMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }
private void Initialize() { // Create a new ArcGISVectorTiledLayer with the navigation serice Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_navigationUrl)); // Create new Map with basemap Map myMap = new Map(new Basemap(_vectorTiledLayer)); // Assign the map to the MapView MyMapView.Map = myMap; }
private void OnVectorLayersChooserSelectionChanged(object sender, SelectionChangedEventArgs e) { // Get the user's selection var selectedVectorLayer = e.AddedItems[0].ToString(); // Get the URL from the dictionary Uri vectorTiledLayerUrl = _layerUrls[selectedVectorLayer]; // Create a new ArcGISVectorTiledLayer with the URI Selected by the user ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(vectorTiledLayerUrl); // Create new Map with basemap MyMapView.Map = new Map(new Basemap(vectorTiledLayer)); }
private void Initialize() { // Create a new ArcGISVectorTiledLayer with the navigation service Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_navigationUrl)); // Create new Map with basemap Map myMap = new Map(new Basemap(_vectorTiledLayer)); // Set titles as a items source vectorLayersChooser.ItemsSource = _vectorLayerNames; // Assign the map to the MapView MyMapView.Map = myMap; }
public static async Task <ArcGISVectorTiledLayer> GetVectorTileLayer(string url) { ArcGISVectorTiledLayer _vectorTiledLayer = null; try { _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(url)); await _vectorTiledLayer.LoadAsync(); } catch (Exception) { } return(_vectorTiledLayer); }
private void Initialize() { // Create a new ArcGISVectorTiledLayer ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls.Values.First()); // Create new Map with basemap Map myMap = new Map(new Basemap(vectorTiledLayer)); // Set titles as items source VectorLayersChooser.ItemsSource = _layerUrls.Keys; // Select the first item VectorLayersChooser.SelectedIndex = 0; // Assign the map to the MapView MyMapView.Map = myMap; }
private void Initialize() { // Create a new ArcGISVectorTiledLayer with the navigation service Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_navigationUrl)); // Create new Map with basemap Map myMap = new Map(new Basemap(_vectorTiledLayer)); // Set titles as a items source vectorLayersChooser.ItemsSource = _vectorLayerNames; // Set the initial selection vectorLayersChooser.SelectedIndex = 3; // Assign the map to the MapView MyMapView.Map = myMap; }
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { var map = new Map(BasemapType.DarkGrayCanvasVector, 39.8283, -98.5795, 5); //add map image layer var mapImageUri = new Uri("http://sampleserver5.arcgisonline.com/arcgis/rest/services/Elevation/WorldElevations/MapServer"); ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(mapImageUri); map.OperationalLayers.Add(imageLayer); //add map tiled layer var tileUri = new Uri("http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer"); ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tileUri); map.OperationalLayers.Add(tiledLayer); //add vector tile layer var vectorUri = new Uri("http://www.arcgis.com/home/item.html?id=75f4dfdff19e445395653121a95a85db"); ArcGISVectorTiledLayer vector = new ArcGISVectorTiledLayer(vectorUri); map.OperationalLayers.Add(vector); //add raster layer var rasterUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer"); ImageServiceRaster rasterService = new ImageServiceRaster(rasterUri); // Create new image service raster from the Uri await rasterService.LoadAsync(); // Load the image service raster RasterLayer raster = new RasterLayer(rasterService); // Create a new raster layer from the image service raster map.OperationalLayers.Add(raster); // Add the raster layer to the maps layer collection //Add feature layer us cities var featUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"); FeatureLayer usCities = new FeatureLayer(featUri); map.OperationalLayers.Add(usCities); //add feature layer world cities var featUri1 = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/0"); FeatureLayer worldCities = new FeatureLayer(featUri1); map.OperationalLayers.Add(worldCities); MyMapView.Map = map; }
private async void OnChangeLayerButtonClicked(object sender, EventArgs e) { // Show sheet and get title from the selection var selectedLayer = await DisplayActionSheet("Select layer", "Cancel", null, _layerUrls.Keys.ToArray()); // If selected cancel do nothing if (selectedLayer == "Cancel") { return; } // Create a new ArcGISVectorTiledLayer with the URL Selected by the user ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls[selectedLayer]); // Create new Map with basemap and assigning to the MapView's Map MyMapView.Map = new Map(new Basemap(vectorTiledLayer)); }
private async void OnChangeLayerButtonClicked(object sender, EventArgs e) { // Get list of layer names as array to show in an action sheet string[] layerNames = _layerUrls.Keys.ToArray(); // Show sheet and get title from the selection string selectedLayer = await((Page)Parent).DisplayActionSheet("Select layer", "Cancel", null, layerNames); // If selected cancel do nothing if (selectedLayer == "Cancel") { return; } // Create a new ArcGISVectorTiledLayer with the URL Selected by the user ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(_layerUrls[selectedLayer]); // Create new Map with basemap and assigning to the MapView's Map MyMapView.Map = new Map(new Basemap(vectorTiledLayer)); }
/// <summary> /// Initializes a 2D Map of the campus using the locally stored data /// This map works offline, but if online, is also supplemented by a world map for better reference /// </summary> /// <returns></returns> private async Task InitializeMap() { Basemap basemap = Basemap.CreateTopographic(); var layer = new ArcGISVectorTiledLayer(new Uri(Path.Combine(ProvisionDataHelper.GetDataFolder(), "Basemap/CampusBasemap.vtpk"), UriKind.RelativeOrAbsolute)); await layer.LoadAsync(); basemap.BaseLayers.Add(layer); Map = new Map(SpatialReferences.WebMercator) { Basemap = basemap, InitialViewpoint = new Viewpoint(new MapPoint(-13046209, 4036456, SpatialReferences.WebMercator), 30000), MaxScale = 160, MinScale = 30000 }; await Map.LoadAsync(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Map))); }
private async void CreateStyledVectorBasemap() { string customVectorLayerId = "d2ff12395aeb45998c1b154e25d680e5"; ArcGISPortal arcGISOnline = await ArcGISPortal.CreateAsync(new Uri("https://www.arcgis.com")); PortalItem layerPortalItem = await PortalItem.CreateAsync(arcGISOnline, customVectorLayerId); ArcGISVectorTiledLayer customVectorTileLayer = new ArcGISVectorTiledLayer(layerPortalItem); Basemap vectorLayerBasemap = new Basemap(customVectorTileLayer); Map map = new Map(vectorLayerBasemap); double initialLatitude = 34.09042; double initialLongitude = -118.71511; double initialScale = 300000; map.InitialViewpoint = new Viewpoint(initialLatitude, initialLongitude, initialScale); Map = map; }
private async void OnChangeLayerButtonClicked(object sender, EventArgs e) { // Show sheet and get title from the selection var selectedLayer = await DisplayActionSheet("Select basemap", "Cancel", null, _vectorLayerNames); // If selected cancel do nothing if (selectedLayer == "Cancel") { return; } switch (selectedLayer) { case "Dark gray": _vectorTiledLayerUrl = _darkGrayUrl; break; case "Streets": _vectorTiledLayerUrl = _streetUrl; break; case "Night": _vectorTiledLayerUrl = _nightUrl; break; case "Navigation": _vectorTiledLayerUrl = _navigationUrl; break; default: break; } // Create a new ArcGISVectorTiledLayer with the Url Selected by the user _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // Create new Map with basemap and assigning to the MapView's Map MyMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create a variable to hold the yOffset where the MapView control should start var yOffset = 60; // Create a new MapView control and provide its location coordinates on the frame MapView myMapView = new MapView(); myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset); // Create a new Map instance with the basemap Map myMap = new Map(SpatialReferences.WebMercator); // Create a new ArcGISVectorTiledLayer with the navigation serice Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_navigationUrl)); myMap.Basemap = new Basemap(_vectorTiledLayer); // Assign the Map to the MapView myMapView.Map = myMap; // Create a segmented control to display buttons UISegmentedControl segmentControl = new UISegmentedControl(); segmentControl.Frame = new CoreGraphics.CGRect(10, 8, View.Bounds.Width - 20, 24); segmentControl.InsertSegment("Dark gray", 0, false); segmentControl.InsertSegment("Streets", 1, false); segmentControl.InsertSegment("Night", 2, false); segmentControl.InsertSegment("Navigation", 3, false); segmentControl.SelectedSegment = 0; segmentControl.ValueChanged += (sender, e) => { var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment; switch (selectedSegmentId) { case 0: _vectorTiledLayerUrl = _darkGrayUrl; break; case 1: _vectorTiledLayerUrl = _streetUrl; break; case 2: _vectorTiledLayerUrl = _nightUrl; break; case 3: _vectorTiledLayerUrl = _navigationUrl; break; } // Create a new ArcGISVectorTiledLayer with the Url Selected by the user _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // Create new Map with basemap and assigning to the Mapviews Map myMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }; // Create a UIBarButtonItem where its view is the SegmentControl UIBarButtonItem barButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); barButtonItem.CustomView = segmentControl; // Create a toolbar on the bottom of the display UIToolbar toolbar = new UIToolbar(); toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height); toolbar.AutosizesSubviews = true; // Add the bar button item to an array of UIBarButtonItems UIBarButtonItem[] barButtonItems = new UIBarButtonItem[] { barButtonItem }; // Add the UIBarButtonItems array to the toolbar toolbar.SetItems(barButtonItems, true); View.AddSubviews(myMapView, toolbar); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(MainDataViewModel mainDataViewModel) { // create accent color menu items for the demo this.AccentColors = ThemeManager.Accents .Select(a => new AccentColorMenuData() { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush }) .ToList(); // create metro theme color menu items for the demo this.AppThemes = ThemeManager.AppThemes .Select(a => new AppThemeMenuData() { Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush }) .ToList(); LayerDetailsCommand = new RelayCommand(() => { LayerDetailWindow view = new LayerDetailWindow(); view.ShowDialog(); }, () => mainDataViewModel.SelectedMapView != null); FileOpenCommand = new RelayCommand(() => { Debug.WriteLine("File open"); var dlg = new OpenFileDialog(); dlg.Filter = string.Join("|", new[] { "ArcGIS Runtime Mobile Formats|*.mmpk;*.geodatabase", "Mobile Map Packages|*.mmpk", "Unpacked Mobile Map Packages|*.info", "Mobile Geodatabases|*.geodatabase", "All Files|*.*" }); if (dlg.ShowDialog() == true) { var selectedPath = dlg.FileName; if (selectedPath.EndsWith(".info")) { selectedPath = System.IO.Path.GetDirectoryName(selectedPath); } FilePath = selectedPath; } }); InspectMmpkCommand = new RelayCommand(() => { var inspectWindow = new InspectWindow { DataContext = mainDataViewModel.Mmpk }; inspectWindow.Show(); }, () => mainDataViewModel.Mmpk != null); InspectGeodatabaseCommand = new RelayCommand(() => { var inspectWindow = new InspectWindow { DataContext = mainDataViewModel.Geodatabase }; inspectWindow.Show(); }, () => mainDataViewModel.Geodatabase != null); InspectMapCommand = new RelayCommand(() => { var inspectWindow = new InspectWindow { DataContext = mainDataViewModel.SelectedMapView.Map }; inspectWindow.Show(); }, () => mainDataViewModel.SelectedMapView != null); InspectLayerCommand = new RelayCommand(() => { var inspectWindow = new InspectWindow { DataContext = mainDataViewModel.SelectedMapView.SelectedLayer }; inspectWindow.Show(); }, () => mainDataViewModel?.SelectedMapView?.SelectedLayer != null); InspectBackgroundGridCommand = new RelayCommand(() => { var inspectWindow = new InspectWindow { DataContext = mainDataViewModel.SelectedMapView.MapView.BackgroundGrid }; inspectWindow.Show(); }, () => mainDataViewModel?.SelectedMapView?.MapView?.BackgroundGrid != null); AddBasemapCommand = new RelayCommand(() => { var map = mainDataViewModel?.SelectedMapView?.Map; if (map != null) { map.Basemap = Basemap.CreateTopographic(); ValidateSpatialReference(map); } }, () => mainDataViewModel.SelectedMapView != null); AddFileBasemapCommand = new RelayCommand(() => { var dlg = new OpenFileDialog(); dlg.Filter = "ArcGIS Offline Basemap Packages|*.tpk;*.vtpk|ArcGIS Tile Package|*.tpk|ArcGIS Vector Tile Package|*.vtpk|All Files (*.*)|*.*"; if (dlg.ShowDialog() == true) { var map = mainDataViewModel?.SelectedMapView?.Map; if (map != null) { switch (System.IO.Path.GetExtension(dlg.FileName).ToLower()) { case ".tpk": var tileCache = new TileCache(dlg.FileName); var tileLayer = new ArcGISTiledLayer(tileCache); map.Basemap = new Basemap(tileLayer); ValidateSpatialReference(map); break; case ".vtpk": //var vectorTileCache = new Esri.ArcGISRuntime.Mapping.VectorTileCache() var vectorTileLayer = new ArcGISVectorTiledLayer(new Uri(dlg.FileName)); map.Basemap = new Basemap(vectorTileLayer); ValidateSpatialReference(map); break; default: break; } } } }, () => mainDataViewModel.SelectedMapView != null); ShowAboutCommand = new RelayCommand(() => { // await((MainWindow)sender).ShowMessageAsync("", $"You clicked on {menuItem.Label} button"); }, () => mainDataViewModel.SelectedMapView != null); ToggleLayerExtentGraphicsVisibility = new RelayCommand(() => { LayerExtentGraphicsVisible = !LayerExtentGraphicsVisible; if (mainDataViewModel.SelectedMapView != null) { mainDataViewModel.SelectedMapView.LayerExtentGraphicsVisible = LayerExtentGraphicsVisible; } }); ToggleBookmarkExtentGraphicsVisibility = new RelayCommand(() => { BookmarkExtentGraphicsVisible = !BookmarkExtentGraphicsVisible; if (mainDataViewModel.SelectedMapView != null) { mainDataViewModel.SelectedMapView.BookmarkExtentGraphicsVisible = BookmarkExtentGraphicsVisible; } }); ZoomToLayerCommand = new RelayCommand(async() => { var mapView = mainDataViewModel?.SelectedMapView?.MapView; if (mapView != null) { var extent = mainDataViewModel.SelectedMapView.SelectedLayer.FullExtent; await mapView.SetViewpointAsync(new Viewpoint(extent)); } }, () => mainDataViewModel?.SelectedMapView?.SelectedLayer != null); PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(FilePath)) { mainDataViewModel.FilePath = FilePath; } if (args.PropertyName == nameof(MapDrawStatus)) { AppStatus = MapDrawStatus.ToString(); } }; }
private void OnVectorLayersMenuItemClicked(object sender, PopupMenu.MenuItemClickEventArgs e) { // Get title from the selected item var selected = e.Item.TitleCondensedFormatted.ToString(); // Get index that is used to get the selected url var selectedIndex = _vectorLayerNames.ToList().IndexOf(selected); switch (selectedIndex) { case 0: _vectorTiledLayerUrl = _darkGrayUrl; break; case 1: _vectorTiledLayerUrl = _streetUrl; break; case 2: _vectorTiledLayerUrl = _nightUrl; break; case 3: _vectorTiledLayerUrl = _navigationUrl; break; } // Create new ArcGISVectorTiled layer with the selected service Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // Create a new map with a basemap that was selected. Assign this to the mapview's map _myMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }
private void Initialize() { _lostTime = DateTime.Now; _currentTime = DateTime.Now.AddHours(0.5); SetRadius(); Console.WriteLine(_radius); Console.WriteLine(DateTime.Now.ToString()); // Create a new map view, set its map, and provide the coordinates for laying it out _mapView = new MapView() { Map = _mapViewModel.Map // Use the map from the view-model }; // Create a new ArcGISVectorTiledLayer with the URI Selected by the user ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri("https://ess.maps.arcgis.com/home/item.html?id=08155fea456d47279946f95134609d05")); // Create new Map with basemap _mapView.Map = new Map(new Basemap(vectorTiledLayer)); _mapView.GeoViewTapped += MyMapView_GeoViewTapped; //Create graphics overlays and add them _bufferOverlay = new GraphicsOverlay(); _barrierOverlay = new GraphicsOverlay(); _interestOverlay = new GraphicsOverlay(); _lostOverlay = new GraphicsOverlay(); _shelter = new MapPoint(-117.203551, 34.060069, SpatialReferences.Wgs84); PictureMarkerSymbol shelterPicture = new PictureMarkerSymbol(new Uri("http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 40, Width = 40 }; _mapView.GraphicsOverlays.Add(_bufferOverlay); _mapView.GraphicsOverlays.Add(_barrierOverlay); _mapView.GraphicsOverlays.Add(_interestOverlay); _mapView.GraphicsOverlays.Add(_lostOverlay); _interestOverlay.Graphics.Add(new Graphic(_shelter, new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.Red, 15))); //get redlands boundary // Create URI to the used feature service. Uri serviceUri = new Uri("https://services.arcgis.com/FLM8UAw9y5MmuVTV/ArcGIS/rest/services/CityLimits_Redlands/FeatureServer/0"); // Create new FeatureLayer by URL. _redlandsBoundary = new FeatureLayer(serviceUri); // Create URI to the used feature service. Uri waterUri = new Uri("https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/Hackathoughts/FeatureServer/1"); _water = new FeatureLayer(waterUri); _water.Renderer = new SimpleRenderer(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 2.0))); //new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 5.0) ); Uri parkUri = new Uri("https://services.arcgis.com/FLM8UAw9y5MmuVTV/ArcGIS/rest/services/Redlands_Park_Boundaries/FeatureServer/0"); _parks = new FeatureLayer(parkUri); Uri buildingsUri = new Uri("https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/Hackathoughts2/FeatureServer/1"); _buildings = new FeatureLayer(buildingsUri); // Add layers to the map. _mapView.Map.OperationalLayers.Add(_redlandsBoundary); _mapView.Map.OperationalLayers.Add(_water); _mapView.Map.OperationalLayers.Add(_parks); _mapView.Map.OperationalLayers.Add(_buildings); _water.LoadAsync(); AsyncInitProcesses(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create a variable to hold the yOffset where the MapView control should start var yOffset = 60; // Create a new MapView control and provide its location coordinates on the frame MapView myMapView = new MapView(); myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset); // Create a new Map instance with the basemap Map myMap = new Map(SpatialReferences.WebMercator); // Create a new ArcGISVectorTiledLayer with the navigation serice Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_navigationUrl)); myMap.Basemap = new Basemap(_vectorTiledLayer); // Assign the Map to the MapView myMapView.Map = myMap; // Create a segmented control to display buttons UISegmentedControl segmentControl = new UISegmentedControl(); segmentControl.Frame = new CoreGraphics.CGRect(10, 8, View.Bounds.Width - 20, 24); segmentControl.InsertSegment("Topo", 0, false); segmentControl.InsertSegment("Streets", 1, false); segmentControl.InsertSegment("Night", 2, false); segmentControl.InsertSegment("Navigation", 3, false); segmentControl.SelectedSegment = 0; segmentControl.ValueChanged += (sender, e) => { var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment; switch (selectedSegmentId) { case 0: _vectorTiledLayerUrl = _topographicUrl; break; case 1: _vectorTiledLayerUrl = _streetUrl; break; case 2: _vectorTiledLayerUrl = _nightUrl; break; case 3: _vectorTiledLayerUrl = _navigationUrl; break; } // Create a new ArcGISVectorTiledLayer with the Url Selected by the user _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // Create new Map with basemap and assigning to the Mapviews Map myMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }; // Create a UIBarButtonItem where its view is the SegmentControl UIBarButtonItem barButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); barButtonItem.CustomView = segmentControl; // Create a toolbar on the bottom of the display UIToolbar toolbar = new UIToolbar(); toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height); toolbar.AutosizesSubviews = true; // Add the bar button item to an array of UIBarButtonItems UIBarButtonItem[] barButtonItems = new UIBarButtonItem[] { barButtonItem }; // Add the UIBarButtonItems array to the toolbar toolbar.SetItems(barButtonItems, true); View.AddSubviews(myMapView, toolbar); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create a new MapView control and provide its location coordinates on the frame _myMapView = new MapView(); // Create a new Map instance with the basemap Map myMap = new Map(SpatialReferences.WebMercator); // Create a new ArcGISVectorTiledLayer with the navigation service Url _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_navigationUrl)); myMap.Basemap = new Basemap(_vectorTiledLayer); // Assign the Map to the MapView _myMapView.Map = myMap; // Update the segmented control to display buttons _segmentControl.InsertSegment("Dark gray", 0, false); _segmentControl.InsertSegment("Streets", 1, false); _segmentControl.InsertSegment("Night", 2, false); _segmentControl.InsertSegment("Navigation", 3, false); _segmentControl.SelectedSegment = 3; _segmentControl.ValueChanged += (sender, e) => { var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment; switch (selectedSegmentId) { case 0: _vectorTiledLayerUrl = _darkGrayUrl; break; case 1: _vectorTiledLayerUrl = _streetUrl; break; case 2: _vectorTiledLayerUrl = _nightUrl; break; case 3: _vectorTiledLayerUrl = _navigationUrl; break; } // Create a new ArcGISVectorTiledLayer with the Url Selected by the user _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // Create new Map with basemap and assigning to the MapView's Map _myMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }; View.AddSubviews(_myMapView, _toolbar, _segmentControl); }
private async void OnChangeLayerButtonClicked(object sender, EventArgs e) { // Show sheet and get title from the selection var selectedLayer = await DisplayActionSheet("Select basemap", "Cancel", null, _vectorLayerNames); // If selected cancel do nothing if (selectedLayer == "Cancel") return; switch (selectedLayer) { case "Dark gray": _vectorTiledLayerUrl = _darkGrayUrl; break; case "Streets": _vectorTiledLayerUrl = _streetUrl; break; case "Night": _vectorTiledLayerUrl = _nightUrl; break; case "Navigation": _vectorTiledLayerUrl = _navigationUrl; break; default: break; } // Create a new ArcGISVectorTiledLayer with the Url Selected by the user _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // // Create new Map with basemap and assigning to the Mapviews Map MyMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }