private async void Initialize()
        {
            // Create a map and add it to the view
            MyMapView.Map = new Map(Basemap.CreateNavigationVector());

            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();

                // Load the sample data
                LoadRasterPaths();

                // Enable the 'choose Raster' button
                MyChooseButton.IsEnabled = true;
            }
            catch (InvalidOperationException 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");
            }
        }
        private void Initialize()
        {
            // Set the initial field selection
            _selectedEntry = DecimalDegreesTextField;

            // Create the map
            MyMapView.Map = new Map(Basemap.CreateNavigationVector());

            // Add the graphics overlay to the map
            MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());

            // Create the starting point
            MapPoint startingPoint = new MapPoint(0, 0, SpatialReferences.WebMercator);

            // Update the UI with the initial point
            UpdateUIFromMapPoint(startingPoint);

            // Subscribe to text change events
            UtmTextField.TextChanged            += InputTextChanged;
            DmsTextField.TextChanged            += InputTextChanged;
            DecimalDegreesTextField.TextChanged += InputTextChanged;
            UsngTextField.TextChanged           += InputTextChanged;

            // Subscribe to map tap events to enable tapping on map to update coordinates
            MyMapView.GeoViewTapped += (sender, args) => { UpdateUIFromMapPoint(args.Location); };
        }
        private async void Initialize()
        {
            // Create the map with basemap.
            _myMapView.Map = new Map(Basemap.CreateNavigationVector());

            try
            {
                // Create the WFS feature table from URL and name.
                WfsFeatureTable wfsTable = new WfsFeatureTable(new Uri(TableUrl), LayerName);

                // Set the feature request mode to manual. Only calls to PopulateFromService will load features.
                // Features will not be populated automatically when the user pans and zooms the layer.
                wfsTable.FeatureRequestMode = FeatureRequestMode.ManualCache;

                // Load the WFS feature table.
                await wfsTable.LoadAsync();

                // Create a feature layer to visualize the WFS feature table.
                FeatureLayer statesLayer = new FeatureLayer(wfsTable);

                // Add the layer to the map.
                _myMapView.Map.OperationalLayers.Add(statesLayer);

                // Populate the WFS feature table with the XML query.
                await wfsTable.PopulateFromServiceAsync(XmlQuery, true);

                // Zoom to the extent of the query results.
                await _myMapView.SetViewpointGeometryAsync(wfsTable.Extent, 50);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "Couldn't populate table with XML query.", null).Show();
            }
        }
Example #4
0
        protected override Task DoInitialize()
        {
            this.BasemapOperations.ToggleDisplay.RegisterExecute(
                (args) =>
            {
                foreach (Layer basemapLayer in args.Map.Map.Basemap.BaseLayers)
                {
                    basemapLayer.IsVisible = args.ToggleOn;
                }

                return(Task.FromResult((object)null));
            }, this);

            this.BasemapOperations.ToggleBasemap.RegisterExecute(
                (args) =>
            {
                if (args.ToggleOn)
                {
                    args.Map.Map.Basemap = Basemap.CreateNavigationVector();
                }
                else
                {
                    args.Map.Map.Basemap = Basemap.CreateStreetsNightVector();
                }


                return(Task.FromResult((object)null));
            }, this);

            return(Task.CompletedTask);
        }
Example #5
0
        // 改变底图
        private void ChangeBaseMap_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Map myMap = myMapView.Map;

            switch (ChangeBaseMap_list.SelectedIndex)
            {
            case 0:
                myMap.Basemap = Basemap.CreateDarkGrayCanvasVector();
                myMapView_Eagle.Map.Basemap = Basemap.CreateDarkGrayCanvasVector();
                break;

            case 1:
                myMap.Basemap = Basemap.CreateImagery();
                myMapView_Eagle.Map.Basemap = Basemap.CreateImagery();
                break;

            case 2:
                myMap.Basemap = Basemap.CreateImageryWithLabels();
                myMapView_Eagle.Map.Basemap = Basemap.CreateImageryWithLabels();
                break;

            case 3:
                myMap.Basemap = Basemap.CreateTerrainWithLabels();
                myMapView_Eagle.Map.Basemap = Basemap.CreateTerrainWithLabels();
                break;

            case 4:
                myMap.Basemap = Basemap.CreateLightGrayCanvas();
                myMapView_Eagle.Map.Basemap = Basemap.CreateLightGrayCanvas();
                break;

            case 5:
                myMap.Basemap = Basemap.CreateTopographic();
                myMapView_Eagle.Map.Basemap = Basemap.CreateTopographic();
                break;

            case 6:
                myMap.Basemap = Basemap.CreateNationalGeographic();
                myMapView_Eagle.Map.Basemap = Basemap.CreateNationalGeographic();
                break;

            case 7:
                myMap.Basemap = Basemap.CreateNavigationVector();
                myMapView_Eagle.Map.Basemap = Basemap.CreateNavigationVector();
                break;

            case 8:
                myMap.Basemap = Basemap.CreateOceans();
                myMapView_Eagle.Map.Basemap = Basemap.CreateOceans();
                break;

            case 9:
                myMap.Basemap = Basemap.CreateStreets();
                myMapView_Eagle.Map.Basemap = Basemap.CreateStreets();
                break;
            }
        }
Example #6
0
        private async void CreateNewMap()
        {
            Map newMap = new Map(Basemap.CreateNavigationVector());

            /*FeatureLayer trailHeadsLayer = new FeatureLayer(new Uri("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0"));
             * await trailHeadsLayer.LoadAsync();
             * newMap.OperationalLayers.Add(trailHeadsLayer);
             */
            newMap.InitialViewpoint = new Viewpoint(33.9737, -117.3281, 20000.0);
            Map = newMap;
        }
Example #7
0
        public View2D()
        {
            InitializeComponent();
            if (mapView.Map == null)
            {
                mapView.Map = new Map(Basemap.CreateNavigationVector());
            }

            mapView.LocationDisplay.InitialZoomScale = 5000;
            mapView.LocationDisplay.AutoPanMode      = Esri.ArcGISRuntime.UI.LocationDisplayAutoPanMode.Navigation;
        }
        public MainWindow()
        {
            // Set the extent of the AOI
            Meters = 100;

            // Set the number of columns
            Columns = 4;

            // Set the Field name
            FieldName = "sidc";

            // Create relative paths to included data
            StylePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"symbols\mil2525c_b2.stylx");
            SidcPath  = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"symbols\SIDC.json");

            // Create the AOI and zoom to it
            MapPoint pnt = GeometryEngine.Project(new MapPoint(-117.1825, 34.0556, SpatialReferences.Wgs84), SpatialReferences.WebMercator) as MapPoint;

            AOI = GeometryEngine.Buffer(pnt, Meters).Extent;

            InitializeComponent();

            MyMapView.Loaded += async(sender, args) =>
            {
                // Create a map using the navigationVector Basemap
                MyMapView.Map = new Map(Basemap.CreateNavigationVector());

                // Create a graphics overlay to display the symbol codes
                MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());

                // Zoom to the aoi
                await MyMapView.SetViewpointGeometryAsync(AOI, 250);

                // Read the symbol identification codes from the json file
                using (System.IO.StreamReader reader = new System.IO.StreamReader(SidcPath))
                {
                    var json = reader.ReadToEnd();
                    Pages = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object>[]>(json);
                }

                Page = 0;
                RenderSymbols(Pages.First(), true);

                btnPrevious.IsEnabled = false;
            };
        }
Example #9
0
        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 async void Initialize()
        {
            // Create a map and add it to the view
            MyMapView.Map = new Map(Basemap.CreateNavigationVector());

            try
            {
                // Start the local server instance
                await LocalServer.Instance.StartAsync();

                // Load the sample data
                LoadRasterPaths();

                // Enable the 'choose Raster' button
                MyChooseButton.IsEnabled = true;
            }
            catch (InvalidOperationException 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");
            }
        }
Example #11
0
        private async void Initialize()
        {
            try
            {
                // Add event handler for when this sample is unloaded.
                Unloaded += SampleUnloaded;

                // Create the map view.
                MyMapView.Map = new Map(Basemap.CreateNavigationVector());

                // Create the route task, using the online routing service.
                RouteTask routeTask = await RouteTask.CreateAsync(_routingUri);

                // Get the default route parameters.
                RouteParameters routeParams = await routeTask.CreateDefaultParametersAsync();

                // Explicitly set values for parameters.
                routeParams.ReturnDirections       = true;
                routeParams.ReturnStops            = true;
                routeParams.ReturnRoutes           = true;
                routeParams.OutputSpatialReference = SpatialReferences.Wgs84;

                // Create stops for each location.
                Stop stop1 = new Stop(_conventionCenter)
                {
                    Name = "San Diego Convention Center"
                };
                Stop stop2 = new Stop(_memorial)
                {
                    Name = "USS San Diego Memorial"
                };
                Stop stop3 = new Stop(_aerospaceMuseum)
                {
                    Name = "RH Fleet Aerospace Museum"
                };

                // Assign the stops to the route parameters.
                List <Stop> stopPoints = new List <Stop> {
                    stop1, stop2, stop3
                };
                routeParams.SetStops(stopPoints);

                // Get the route results.
                _routeResult = await routeTask.SolveRouteAsync(routeParams);

                _route = _routeResult.Routes[0];

                // Add a graphics overlay for the route graphics.
                MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());

                // Add graphics for the stops.
                SimpleMarkerSymbol stopSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.OrangeRed, 20);
                MyMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_conventionCenter, stopSymbol));
                MyMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_memorial, stopSymbol));
                MyMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_aerospaceMuseum, stopSymbol));

                // Create a graphic (with a dashed line symbol) to represent the route.
                _routeAheadGraphic = new Graphic(_route.RouteGeometry)
                {
                    Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.BlueViolet, 5)
                };

                // Create a graphic (solid) to represent the route that's been traveled (initially empty).
                _routeTraveledGraphic = new Graphic {
                    Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.LightBlue, 3)
                };

                // Add the route graphics to the map view.
                MyMapView.GraphicsOverlays[0].Graphics.Add(_routeAheadGraphic);
                MyMapView.GraphicsOverlays[0].Graphics.Add(_routeTraveledGraphic);

                // Set the map viewpoint to show the entire route.
                await MyMapView.SetViewpointGeometryAsync(_route.RouteGeometry, 100);

                // Enable the navigation button.
                StartNavigationButton.IsEnabled = true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error");
            }
        }
Example #12
0
        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);
        }
Example #13
0
        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);
            }
        }
Example #14
0
        private async void Initialize()
        {
            try
            {
                // Create the map view.
                _myMapView.Map = new Map(Basemap.CreateNavigationVector());

                // Create the route task, using the routing service.
                _routeTask = await RouteTask.CreateAsync(_networkGeodatabasePath, "Streets_ND");

                // Get the default route parameters.
                _routeParams = await _routeTask.CreateDefaultParametersAsync();

                // Explicitly set values for parameters.
                _routeParams.ReturnDirections       = true;
                _routeParams.ReturnStops            = true;
                _routeParams.ReturnRoutes           = true;
                _routeParams.OutputSpatialReference = SpatialReferences.Wgs84;

                // Create stops for each location.
                Stop stop1 = new Stop(_conventionCenter)
                {
                    Name = "San Diego Convention Center"
                };
                Stop stop2 = new Stop(_aerospaceMuseum)
                {
                    Name = "RH Fleet Aerospace Museum"
                };

                // Assign the stops to the route parameters.
                List <Stop> stopPoints = new List <Stop> {
                    stop1, stop2
                };
                _routeParams.SetStops(stopPoints);

                // Get the route results.
                _routeResult = await _routeTask.SolveRouteAsync(_routeParams);

                _route = _routeResult.Routes[0];

                // Add a graphics overlay for the route graphics.
                _myMapView.GraphicsOverlays.Add(new GraphicsOverlay());

                // Add graphics for the stops.
                SimpleMarkerSymbol stopSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.OrangeRed, 20);
                _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_conventionCenter, stopSymbol));
                _myMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_aerospaceMuseum, stopSymbol));

                // Create a graphic (with a dashed line symbol) to represent the route.
                _routeAheadGraphic = new Graphic(_route.RouteGeometry)
                {
                    Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.BlueViolet, 5)
                };

                // Create a graphic (solid) to represent the route that's been traveled (initially empty).
                _routeTraveledGraphic = new Graphic {
                    Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.LightBlue, 3)
                };

                // Add the route graphics to the map view.
                _myMapView.GraphicsOverlays[0].Graphics.Add(_routeAheadGraphic);
                _myMapView.GraphicsOverlays[0].Graphics.Add(_routeTraveledGraphic);

                // Set the map viewpoint to show the entire route.
                await _myMapView.SetViewpointGeometryAsync(_route.RouteGeometry, 100);

                // Enable the navigation button.
                _navigateButton.Enabled = true;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.Message, (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }