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 void BasemapCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { int index = BasemapCombobox.SelectedIndex; switch (index) { case 0: MyMapView.Map.Basemap = Basemap.CreateStreetsVector(); break; case 1: MyMapView.Map.Basemap = Basemap.CreateTopographicVector(); break; case 2: MyMapView.Map.Basemap = Basemap.CreateImageryWithLabelsVector(); break; case 3: MyMapView.Map.Basemap = Basemap.CreateStreetsNightVector(); break; default: MyMapView.Map.Basemap = Basemap.CreateOpenStreetMap(); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void CreateNewMap() { Map newMap = new Map(Basemap.CreateOpenStreetMap()); FeatureLayer NeaplAdmin1 = new FeatureLayer(new Uri("https://services.arcgis.com/iQ1dY19aHwbSDYIF/arcgis/rest/services/GAFSP_Nepal_2016/FeatureServer/1")); FeatureLayer NeaplandFood = new FeatureLayer(new Uri("https://services.arcgis.com/iQ1dY19aHwbSDYIF/arcgis/rest/services/GAFSP_Nepal_2016/FeatureServer/2")); FeatureLayer NeaplAirport = new FeatureLayer(new Uri("https://services.arcgis.com/pGfbNJoYypmNq86F/arcgis/rest/services/Nepal_Places_Facilities/FeatureServer/2")); await NeaplAirport.LoadAsync(); await NeaplAdmin1.LoadAsync(); await NeaplandFood.LoadAsync(); newMap.OperationalLayers.Add(NeaplandFood); newMap.OperationalLayers.Add(NeaplAdmin1); newMap.OperationalLayers.Add(NeaplAirport); newMap.InitialViewpoint = new Viewpoint(NeaplAdmin1.FullExtent); Map = newMap; }
public void Load_OpenStreetMap() { MainViewModel.SetBBox(); MyMapView.Map = new Map(Basemap.CreateOpenStreetMap()); MyMapView.SetViewpointCenterAsync(MainViewModel.CenterPoint); MainViewModel.SetBBox(); }
private void Initialize() { // Create the OpenStreetMap basemap. Basemap osmBasemap = Basemap.CreateOpenStreetMap(); // Create the map with the OpenStreetMap basemap. Map osmMap = new Map(osmBasemap); // Show the map in the view. _myMapView.Map = osmMap; }
// Note: all code below (except call to ConfigureOfflineJobForBasemap) is identical to code in the Generate offline map sample. #region Generate offline map private void Initialize() { try { // Display the map in the MapView. MyMapView.Map = new Map(Basemap.CreateOpenStreetMap());; // Disable user interactions on the map (no panning or zooming from the initial extent). MyMapView.InteractionOptions = new MapViewInteractionOptions { IsEnabled = false }; // Create a graphics overlay for the extent graphic and apply a renderer. SimpleLineSymbol aoiOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Red, 3); GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(aoiOutlineSymbol) }; MyMapView.GraphicsOverlays.Add(extentOverlay); // Add a graphic to show the area of interest (extent) that will be taken offline. Graphic aoiGraphic = new Graphic(_areaOfInterest); extentOverlay.Graphics.Add(aoiGraphic); // Hide the map loading progress indicator. LoadingIndicator.Visibility = Visibility.Collapsed; // When the map view unloads, try to clean up existing output data folders. MyMapView.Unloaded += (s, e) => { // Find output mobile map folders in the temp directory. string[] outputFolders = Directory.GetDirectories(Environment.ExpandEnvironmentVariables("%TEMP%"), "NapervilleWaterNetwork*"); // Loop through the folder names and delete them. foreach (string dir in outputFolders) { try { // Delete the folder. Directory.Delete(dir, true); } catch (Exception) { // Ignore exceptions (files might be locked, for example). } } }; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error loading map"); } }
private void Initialize() { Map myMap = new Map(Basemap.CreateOpenStreetMap()); Envelope initialLocation = new Envelope( 136.6, 35.72, 139.65, 35.68, SpatialReferences.Wgs84); myMap.InitialViewpoint = new Viewpoint(initialLocation); MyMapView.Map = myMap; }
public static Basemap FromBasemapType(this BasemapType type) { switch (type) { case BasemapType.DarkGrayCanvasVector: return(Basemap.CreateDarkGrayCanvasVector()); case BasemapType.Imagery: return(Basemap.CreateImagery()); case BasemapType.ImageryWithLabels: return(Basemap.CreateImageryWithLabels()); case BasemapType.ImageryWithLabelsVector: return(Basemap.CreateImageryWithLabelsVector()); case BasemapType.LightGrayCanvas: return(Basemap.CreateLightGrayCanvas()); case BasemapType.LightGrayCanvasVector: return(Basemap.CreateLightGrayCanvasVector()); case BasemapType.NationalGeographic: return(Basemap.CreateNationalGeographic()); case BasemapType.NavigationVector: return(Basemap.CreateNavigationVector()); case BasemapType.Oceans: return(Basemap.CreateOceans()); case BasemapType.OpenStreetMap: return(Basemap.CreateOpenStreetMap()); case BasemapType.Streets: return(Basemap.CreateStreets()); case BasemapType.StreetsNightVector: return(Basemap.CreateStreetsNightVector()); case BasemapType.StreetsVector: return(Basemap.CreateStreetsVector()); case BasemapType.StreetsWithReliefVector: return(Basemap.CreateStreetsWithReliefVector()); case BasemapType.TerrainWithLabels: return(Basemap.CreateTerrainWithLabels()); case BasemapType.TerrainWithLabelsVector: return(Basemap.CreateTerrainWithLabelsVector()); case BasemapType.Topographic: return(Basemap.CreateTopographic()); case BasemapType.TopographicVector: return(Basemap.CreateTopographicVector()); default: throw new NotImplementedException(type.ToString()); } }
private void toc_LayerContentContextMenuOpening(object sender, Preview.UI.Controls.TableOfContentsContextMenuEventArgs args) { if (args.TableOfContentItem is Mapping.Basemap) { var item = new MenuItem() { Header = "Imagery" }; item.Click += (s, e) => mapView.Map.Basemap = Basemap.CreateImagery(); args.MenuItems.Add(item); item = new MenuItem() { Header = "Streets" }; item.Click += (s, e) => mapView.Map.Basemap = Basemap.CreateStreetsVector(); args.MenuItems.Add(item); item = new MenuItem() { Header = "OpenStreetMap" }; item.Click += (s, e) => mapView.Map.Basemap = Basemap.CreateOpenStreetMap(); args.MenuItems.Add(item); } if (args.TableOfContentItem is Mapping.Layer layer) { if (layer.LoadStatus == LoadStatus.FailedToLoad) { var retry = new MenuItem() { Header = "Retry load" }; retry.Click += (s, e) => layer.RetryLoadAsync(); args.MenuItems.Add(retry); return; } if (layer.FullExtent != null) { var zoomTo = new MenuItem() { Header = "Zoom To" }; zoomTo.Click += (s, e) => mapView.SetViewpointGeometryAsync(layer.FullExtent); args.MenuItems.Add(zoomTo); } if (args.MenuItems.Count > 0) { args.MenuItems.Add(new Separator()); } var remove = new MenuItem() { Header = "Remove" }; remove.Click += (s, e) => { var result = MessageBox.Show("Remove layer " + layer.Name + " ?", "Confirm", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { if (mapView.Map.OperationalLayers.Contains(layer)) { mapView.Map.OperationalLayers.Remove(layer); } } }; args.MenuItems.Add(remove); } }
public Basemap GetBasemap(BasemapType basemapType) { Basemap basemap = null; switch (basemapType) { case BasemapType.Imagery: basemap = Basemap.CreateImagery(); break; case BasemapType.ImageryWithLabels: basemap = Basemap.CreateImageryWithLabels(); break; case BasemapType.Streets: basemap = Basemap.CreateStreets(); break; case BasemapType.Topographic: basemap = Basemap.CreateTopographic(); break; case BasemapType.TerrainWithLabels: basemap = Basemap.CreateTerrainWithLabels(); break; case BasemapType.LightGrayCanvas: basemap = Basemap.CreateLightGrayCanvas(); break; case BasemapType.NationalGeographic: basemap = Basemap.CreateNationalGeographic(); break; case BasemapType.Oceans: basemap = Basemap.CreateOceans(); break; case BasemapType.OpenStreetMap: basemap = Basemap.CreateOpenStreetMap(); break; case BasemapType.ImageryWithLabelsVector: basemap = Basemap.CreateImageryWithLabelsVector(); break; case BasemapType.StreetsVector: basemap = Basemap.CreateStreetsVector(); break; case BasemapType.TopographicVector: basemap = Basemap.CreateTopographicVector(); break; case BasemapType.TerrainWithLabelsVector: basemap = Basemap.CreateTerrainWithLabelsVector(); break; case BasemapType.LightGrayCanvasVector: basemap = Basemap.CreateLightGrayCanvasVector(); break; case BasemapType.NavigationVector: basemap = Basemap.CreateNavigationVector(); break; case BasemapType.StreetsNightVector: basemap = Basemap.CreateStreetsVector(); break; case BasemapType.StreetsWithReliefVector: basemap = Basemap.CreateStreetsWithReliefVector(); break; case BasemapType.DarkGrayCanvasVector: basemap = Basemap.CreateDarkGrayCanvasVector(); break; default: break; } return(basemap); }
private void toc_LayerContentContextMenuOpening(object sender, Preview.UI.Controls.TocItemContextMenuEventArgs args) { var tocItem = args.Item; if (tocItem.Content is Mapping.Basemap) { var item = new MenuItem() { Header = "Imagery" }; item.Click += (s, e) => mapView.Map.Basemap = Basemap.CreateImagery(); args.MenuItems.Add(item); item = new MenuItem() { Header = "Streets" }; item.Click += (s, e) => mapView.Map.Basemap = Basemap.CreateStreetsVector(); args.MenuItems.Add(item); item = new MenuItem() { Header = "OpenStreetMap" }; item.Click += (s, e) => mapView.Map.Basemap = Basemap.CreateOpenStreetMap(); args.MenuItems.Add(item); } if (tocItem.Content is ILoadable loadable && loadable.LoadStatus == LoadStatus.FailedToLoad) { var retry = new MenuItem() { Header = "Retry load", Icon = new TextBlock() { Text = "", FontFamily = new FontFamily("Segoe UI Symbol") } }; retry.Click += (s, e) => loadable.RetryLoadAsync(); args.MenuItems.Add(retry); return; } if (tocItem.Content is FeatureLayer fl) { var resetRenderer = new MenuItem() { Header = "Reset Renderer" }; resetRenderer.Click += (s, e) => fl.Renderer = new Symbology.SimpleRenderer(new Symbology.SimpleMarkerSymbol() { Color = System.Drawing.Color.Red }); args.MenuItems.Add(resetRenderer); } if (!(tocItem.Content is LegendInfo)) { Func <Task <Envelope> > getExtent = null; if (tocItem.Layer?.FullExtent != null) { getExtent = () => Task.FromResult(tocItem.Layer?.FullExtent); } if (tocItem.Content is ArcGISSublayer sublayer) { if (sublayer.LoadStatus == LoadStatus.NotLoaded || sublayer.LoadStatus == LoadStatus.Loading) { getExtent = async() => { try { await sublayer.LoadAsync(); } catch { return(null); } return(sublayer.MapServiceSublayerInfo?.Extent); }; } else if (sublayer.MapServiceSublayerInfo?.Extent != null) { getExtent = () => Task.FromResult(sublayer.MapServiceSublayerInfo.Extent); } } if (getExtent != null) { var zoomTo = new MenuItem() { Header = "Zoom To", Icon = new TextBlock() { Text = "", FontFamily = new FontFamily("Segoe UI Symbol") } }; zoomTo.Click += async(s, e) => { var extent = await getExtent(); if (extent != null) { _ = mapView.SetViewpointGeometryAsync(extent); } }; args.MenuItems.Add(zoomTo); } } if (args.MenuItems.Count > 0) { args.MenuItems.Add(new Separator()); } if (tocItem.Content is Layer layer) { var remove = new MenuItem() { Header = "Remove", Icon = new TextBlock() { Text = "", FontFamily = new FontFamily("Segoe UI Symbol") } }; remove.Click += (s, e) => { var result = MessageBox.Show("Remove layer " + layer.Name + " ?", "Confirm", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { if (mapView.Map.OperationalLayers.Contains(layer)) { mapView.Map.OperationalLayers.Remove(layer); } } }; args.MenuItems.Add(remove); } }
public Basemap GetBaseMap(CusMapView cusMapView) { switch (cusMapView.Map.MapType) { case MapType.Imagery: return(Basemap.CreateImagery()); case MapType.Streets: return(Basemap.CreateStreets()); case MapType.ImageryWithLabels: return(Basemap.CreateImageryWithLabels()); case MapType.ImageryWithLabelsVector: return(Basemap.CreateImageryWithLabelsVector()); case MapType.LightGrayCanvas: return(Basemap.CreateLightGrayCanvas()); case MapType.LightGrayCanvasVector: return(Basemap.CreateLightGrayCanvasVector()); case MapType.DarkGrayCanvasVector: return(Basemap.CreateDarkGrayCanvasVector()); case MapType.NationalGeographic: return(Basemap.CreateNationalGeographic()); case MapType.Oceans: return(Basemap.CreateOceans()); case MapType.StreetsVector: return(Basemap.CreateStreetsVector()); case MapType.StreetsWithReliefVector: return(Basemap.CreateStreetsWithReliefVector()); case MapType.StreetsNightVector: return(Basemap.CreateStreetsNightVector()); case MapType.NavigationVector: return(Basemap.CreateNavigationVector()); case MapType.TerrainWithLabels: return(Basemap.CreateTerrainWithLabels()); case MapType.TerrainWithLabelsVector: return(Basemap.CreateTerrainWithLabelsVector()); case MapType.Topographic: return(Basemap.CreateTopographic()); case MapType.TopographicVector: return(Basemap.CreateTopographicVector()); case MapType.OpenStreetMap: return(Basemap.CreateOpenStreetMap()); case MapType.WebMap: if (!string.IsNullOrEmpty(cusMapView.Map.WebMapUrl)) { return(new Basemap(new Uri(cusMapView.Map.WebMapUrl))); } throw new ArgumentOutOfRangeException(nameof(cusMapView.Map.WebMapUrl), cusMapView.Map.WebMapUrl, null); default: throw new ArgumentOutOfRangeException(nameof(cusMapView.Map.MapType), cusMapView.Map.MapType, null); } }
public MapViewModel() { Map = new Map(Basemap.CreateOpenStreetMap()); LoadFeatureLayer(); SearchText = "pool_permit = 0"; }