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); } }
private async void Initialize() { // Hook up the DrawStatusChanged event. MyMapView.DrawStatusChanged += OnDrawStatusChanged; // Construct the map and set the MapView.Map property. Map map = new Map(Basemap.CreateLightGrayCanvasVector()); MyMapView.Map = map; try { // Create a ClosestFacilityTask using the San Diego Uri. _task = await ClosestFacilityTask.CreateAsync(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ClosestFacility")); // List of facilities to be placed around San Diego area. _facilities = new List <Facility> { new Facility(new MapPoint(-1.3042129900625112E7, 3860127.9479775648, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3042193400557665E7, 3862448.873041752, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3046882875518233E7, 3862704.9896770366, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3040539754780494E7, 3862924.5938606677, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3042571225655518E7, 3858981.773018156, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3039784633928463E7, 3856692.5980474586, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3049023883956768E7, 3861993.789732541, SpatialReferences.WebMercator)) }; // Center the map on the San Diego facilities. Envelope fullExtent = GeometryEngine.CombineExtents(_facilities.Select(facility => facility.Geometry)); await MyMapView.SetViewpointGeometryAsync(fullExtent, 50); // Create a symbol for displaying facilities. _facilitySymbol = new PictureMarkerSymbol(new Uri("https://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 30, Width = 30 }; // Incident symbol. _incidentSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.FromArgb(255, 0, 0, 0), 30); // Route to hospital symbol. _routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(255, 0, 0, 255), 5.0f); // Create Graphics Overlays for incidents and facilities. _incidentGraphicsOverlay = new GraphicsOverlay(); _facilityGraphicsOverlay = new GraphicsOverlay(); // Create a graphic and add to graphics overlay for each facility. foreach (Facility facility in _facilities) { _facilityGraphicsOverlay.Graphics.Add(new Graphic(facility.Geometry, _facilitySymbol)); } // Add each graphics overlay to MyMapView. MyMapView.GraphicsOverlays.Add(_incidentGraphicsOverlay); MyMapView.GraphicsOverlays.Add(_facilityGraphicsOverlay); } catch (Exception e) { await new MessageDialog(e.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { try { // Construct the map and set the MapView.Map property. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); // Add a graphics overlay to MyMapView. (Will be used later to display routes) _myMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Create a ClosestFacilityTask using the San Diego Uri. _task = await ClosestFacilityTask.CreateAsync(_closestFacilityUri); // Create a symbol for displaying facilities. PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(new Uri("https://static.arcgis.com/images/Symbols/SafetyHealth/FireStation.png")) { Height = 30, Width = 30 }; // Incident symbol. PictureMarkerSymbol incidentSymbol = new PictureMarkerSymbol(new Uri("https://static.arcgis.com/images/Symbols/SafetyHealth/esriCrimeMarker_56_Gradient.png")) { Height = 30, Width = 30 }; // Create a list of line symbols to show unique routes. Different colors help make different routes visually distinguishable. _routeSymbols = new List <SimpleLineSymbol>() { new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 25, 45, 85), 5.0f), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 35, 65, 120), 5.0f), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 55, 100, 190), 5.0f), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 75, 140, 255), 5.0f) }; // Create a table for facilities using the FeatureServer. _facilityTable = new ServiceFeatureTable(_facilityUri); // Create a feature layer from the table. _facilityLayer = new FeatureLayer(_facilityTable) { Renderer = new SimpleRenderer(facilitySymbol) }; // Create a table for facilities using the FeatureServer. _incidentTable = new ServiceFeatureTable(_incidentUri); // Create a feature layer from the table. _incidentLayer = new FeatureLayer(_incidentTable) { Renderer = new SimpleRenderer(incidentSymbol) }; // Add the layers to the map. _myMapView.Map.OperationalLayers.Add(_facilityLayer); _myMapView.Map.OperationalLayers.Add(_incidentLayer); // Wait for both layers to load. await _facilityLayer.LoadAsync(); await _incidentLayer.LoadAsync(); // Zoom to the combined extent of both layers. Envelope fullExtent = GeometryEngine.CombineExtents(_facilityLayer.FullExtent, _incidentLayer.FullExtent); await _myMapView.SetViewpointGeometryAsync(fullExtent, 50); // Enable the solve button. _solveRoutesButton.Enabled = true; } catch (Exception exception) { CreateErrorDialog("An exception has occurred.\n" + exception.Message); } }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); // Load the tiled layer and get the path string rasterPath = GetRasterPath(); // Create a tile cache using the path to the raster TileCache myTileCache = new TileCache(rasterPath); // Create the tiled layer from the tile cache ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(myTileCache); // Try to load the tiled layer try { // Wait for the layer to load await tiledLayer.LoadAsync(); // Zoom to extent of the tiled layer await MyMapView.SetViewpointGeometryAsync(tiledLayer.FullExtent); } catch (Exception) { MessageBox.Show("Couldn't load the tile package, ending sample load."); return; } // Add the layer to the map MyMapView.Map.OperationalLayers.Add(tiledLayer); // Try to start Local Server 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(); } catch (Exception ex) { MessageBox.Show(String.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md. Message: {0}", ex.Message), "Local Server failed to start"); return; } // Get the path to the geoprocessing task string gpServiceUrl = GetGpPath(); // Create the geoprocessing service _gpService = new LocalGeoprocessingService(gpServiceUrl, GeoprocessingServiceType.AsynchronousSubmitWithMapServiceResult); // Take action once the service loads _gpService.StatusChanged += GpServiceOnStatusChanged; // Try to start the service try { // Start the service await _gpService.StartAsync(); } catch (Exception) { MessageBox.Show("geoprocessing service failed to start."); } }
private async void Initialize() { // Create a map and add it to the view MyMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); // Load the tiled layer and get the path string rasterPath = await GetRasterPath(); // Create a tile cache using the path to the raster TileCache myTileCache = new TileCache(rasterPath); // Create the tiled layer from the tile cache ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(myTileCache); // Try to load the tiled layer try { // Wait for the layer to load await tiledLayer.LoadAsync(); // Zoom to extent of the tiled layer await MyMapView.SetViewpointGeometryAsync(tiledLayer.FullExtent); } catch (Exception) { MessageBox.Show("Couldn't load the tile package, ending sample load."); return; } // Add the layer to the map MyMapView.Map.OperationalLayers.Add(tiledLayer); // Try to start Local Server try { // Start the local server instance await LocalServer.Instance.StartAsync(); } 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"); return; } // Get the path to the geoprocessing task string gpServiceUrl = await GetGpPath(); // Create the geoprocessing service _gpService = new LocalGeoprocessingService(gpServiceUrl, GeoprocessingServiceType.AsynchronousSubmitWithMapServiceResult); // Take action once the service loads _gpService.StatusChanged += GpServiceOnStatusChanged; // Try to start the service try { // Start the service await _gpService.StartAsync(); } catch (Exception) { MessageBox.Show("geoprocessing service failed to start."); } }
public MapViewModel() { Map = new Map(Basemap.CreateLightGrayCanvasVector()); }
public CompassSceneViewSample() { InitializeComponent(); sceneView.Scene = new Scene(Basemap.CreateLightGrayCanvasVector()); }
public CompassMapViewSample() { InitializeComponent(); mapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); }