コード例 #1
0
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map map = new Map(Basemap.CreateStreets());

            // Get the file name for the local raster dataset.
            string filepath = GetRasterPath();

            // Load the raster file
            Raster rasterFile = new Raster(filepath);

            // Create a new raster layer to show the image.
            _rasterLayer = new RasterLayer(rasterFile);

            try
            {
                // Once the layer has loaded, enable the button to change the renderer.
                await _rasterLayer.LoadAsync();

                ApplyRgbRendererButton.IsEnabled = true;

                // Create a viewpoint with the raster's full extent.
                Viewpoint fullRasterExtent = new Viewpoint(_rasterLayer.FullExtent);

                // Set the initial viewpoint for the map.
                map.InitialViewpoint = fullRasterExtent;

                // Add the layer to the map.
                map.OperationalLayers.Add(_rasterLayer);

                // Add the map to the map view.
                MyMapView.Map = map;

                // Add available stretch types to the combo box.
                StretchTypeComboBox.Items.Add("Min Max");
                StretchTypeComboBox.Items.Add("Percent Clip");
                StretchTypeComboBox.Items.Add("Standard Deviation");

                // Select "Min Max" as the stretch type.
                StretchTypeComboBox.SelectedIndex = 0;

                // Create a range of values from 0-255.
                IList minMaxValues = Enumerable.Range(0, 256).ToList();

                // Fill the min and max red combo boxes with the range and set default values.
                MinRedComboBox.ItemsSource  = minMaxValues;
                MinRedComboBox.SelectedItem = 0;
                MaxRedComboBox.ItemsSource  = minMaxValues;
                MaxRedComboBox.SelectedItem = 255;

                // Fill the min and max green combo boxes with the range and set default values.
                MinGreenComboBox.ItemsSource  = minMaxValues;
                MinGreenComboBox.SelectedItem = 0;
                MaxGreenComboBox.ItemsSource  = minMaxValues;
                MaxGreenComboBox.SelectedItem = 255;

                // Fill the min and max blue combo boxes with the range and set default values.
                MinBlueComboBox.ItemsSource  = minMaxValues;
                MinBlueComboBox.SelectedItem = 0;
                MaxBlueComboBox.ItemsSource  = minMaxValues;
                MaxBlueComboBox.SelectedItem = 255;

                // Fill the standard deviation factor combo box and set a default value.
                IEnumerable <int> wholeStdDevs = Enumerable.Range(1, 10);
                List <double>     halfStdDevs  = wholeStdDevs.Select(i => (double)i / 2).ToList();
                StdDeviationFactorComboBox.ItemsSource  = halfStdDevs;
                StdDeviationFactorComboBox.SelectedItem = 2.0;
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
コード例 #2
0
        private async void Initialize()
        {
            // Create new map with the streets basemap
            Map myMap = new Map(Basemap.CreateStreets());

            // Create a Uri to the image service raster (NOTE: iOS applications require the use of Uri's to be https:// and not http://)
            Uri myUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer");

            // Create new image service raster from the Uri
            ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(myUri);

            try
            {
                // Load the image service raster
                await myImageServiceRaster.LoadAsync();

                // NOTE: This is the ASCII text for actual raw JSON string:
                // ========================================================
                //{
                //  "raster_function_arguments":
                //  {
                //    "z_factor":{"double":25.0,"type":"Raster_function_variable"},
                //    "slope_type":{"raster_slope_type":"none","type":"Raster_function_variable"},
                //    "azimuth":{"double":315,"type":"Raster_function_variable"},
                //    "altitude":{"double":45,"type":"Raster_function_variable"},
                //    "type":"Raster_function_arguments",
                //    "raster":{"name":"raster","is_raster":true,"type":"Raster_function_variable"},
                //    "nbits":{"int":8,"type":"Raster_function_variable"}
                //  },
                //  "raster_function":{"type":"Hillshade_function"},
                //  "type":"Raster_function_template"
                //}

                // Define the JSON string needed for the raster function
                string theJSON_String =
                    @"{
                ""raster_function_arguments"":
                {
                  ""z_factor"":{ ""double"":25.0,""type"":""Raster_function_variable""},
                  ""slope_type"":{ ""raster_slope_type"":""none"",""type"":""Raster_function_variable""},
                  ""azimuth"":{ ""double"":315,""type"":""Raster_function_variable""},
                  ""altitude"":{ ""double"":45,""type"":""Raster_function_variable""},
                  ""type"":""Raster_function_arguments"",
                  ""raster"":{ ""name"":""raster"",""is_raster"":true,""type"":""Raster_function_variable""},
                  ""nbits"":{ ""int"":8,""type"":""Raster_function_variable""}
                },
              ""raster_function"":{ ""type"":""Hillshade_function""},
              ""type"":""Raster_function_template""
            }";

                // Create a raster function from the JSON string using the static/Shared method called: RasterFunction.FromJson(json as String)
                RasterFunction myRasterFunction = RasterFunction.FromJson(theJSON_String);

                // NOTE: Depending on your platform/device, you could have alternatively created the raster function via a JSON string that is contained in a
                // file on disk (ex: hillshade_simplified.json) via the constructor: Esri.ArcGISRuntime.Rasters.RasterFunction(path as String)

                // Get the raster function arguments
                RasterFunctionArguments myRasterFunctionArguments = myRasterFunction.Arguments;

                // Get the list of names from the raster function arguments
                IReadOnlyList <string> myRasterNames = myRasterFunctionArguments.GetRasterNames();

                // Apply the first raster name and image service raster in the raster function arguments
                myRasterFunctionArguments.SetRaster(myRasterNames[0], myImageServiceRaster);

                // Create a new raster based on the raster function
                Raster myRaster = new Raster(myRasterFunction);

                // Create a new raster layer from the raster
                RasterLayer myRasterLayer = new RasterLayer(myRaster);

                // Add the raster layer to the maps layer collection
                myMap.Basemap.BaseLayers.Add(myRasterLayer);

                // Assign the map to the map view
                MyMapView.Map = myMap;

                // Get the service information (aka. metadata) about the image service raster
                ArcGISImageServiceInfo myArcGISImageServiceInfo = myImageServiceRaster.ServiceInfo;

                // Zoom the map to the extent of the image service raster (which also the extent of the raster layer)
                await MyMapView.SetViewpointGeometryAsync(myArcGISImageServiceInfo.FullExtent);

                // NOTE: The sample zooms to the extent of the ImageServiceRaster. Currently the ArcGIS Runtime does not
                // support zooming a RasterLayer out beyond 4 times it's published level of detail. The sample uses
                // MapView.SetViewpointCenterAsync() method to ensure the image shows when the app starts. You can see
                // the effect of the image service not showing when you zoom out to the full extent of the image and beyond.
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
コード例 #3
0
        private async void Initialize()
        {
            try
            {
                // Create the map view.
                _myMapView.Map = new Map(Basemap.CreateStreets());

                // Create the text to speech object.
                _textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

                // 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 AlertDialog.Builder(this).SetMessage(e.Message).SetTitle("Error").Show();
            }
        }
        private async void Initialize()
        {
            // Create new map with the streets basemap.
            Map myMap = new Map(Basemap.CreateStreets());

            // Create a URI to the image service raster.
            Uri rasterUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer");

            // Create new image service raster from the URI.
            ImageServiceRaster imageServiceRaster = new ImageServiceRaster(rasterUri);

            try
            {
                // Load the image service raster.
                await imageServiceRaster.LoadAsync();

                // NOTE: This is the ASCII text for actual raw JSON string:
                // ========================================================
                //{
                //  "raster_function_arguments":
                //  {
                //    "z_factor":{"double":25.0,"type":"Raster_function_variable"},
                //    "slope_type":{"raster_slope_type":"none","type":"Raster_function_variable"},
                //    "azimuth":{"double":315,"type":"Raster_function_variable"},
                //    "altitude":{"double":45,"type":"Raster_function_variable"},
                //    "type":"Raster_function_arguments",
                //    "raster":{"name":"raster","is_raster":true,"type":"Raster_function_variable"},
                //    "nbits":{"int":8,"type":"Raster_function_variable"}
                //  },
                //  "raster_function":{"type":"Hillshade_function"},
                //  "type":"Raster_function_template"
                //}

                // Define the JSON string needed for the raster function
                const string theJsonString = @"{
                ""raster_function_arguments"":
                {
                  ""z_factor"":{ ""double"":25.0,""type"":""Raster_function_variable""},
                  ""slope_type"":{ ""raster_slope_type"":""none"",""type"":""Raster_function_variable""},
                  ""azimuth"":{ ""double"":315,""type"":""Raster_function_variable""},
                  ""altitude"":{ ""double"":45,""type"":""Raster_function_variable""},
                  ""type"":""Raster_function_arguments"",
                  ""raster"":{ ""name"":""raster"",""is_raster"":true,""type"":""Raster_function_variable""},
                  ""nbits"":{ ""int"":8,""type"":""Raster_function_variable""}
                },
              ""raster_function"":{ ""type"":""Hillshade_function""},
              ""type"":""Raster_function_template""
            }";

                // Create a raster function from the JSON string using the static/Shared method called: RasterFunction.FromJson(JSON as String).
                RasterFunction rasterFunction = RasterFunction.FromJson(theJsonString);

                // NOTE: You could have alternatively created the raster function via a JSON string that is contained in a
                // file on disk (ex: hillshade_simplified.json) via the constructor: Esri.ArcGISRuntime.Rasters.RasterFunction(path as String).

                // Get the raster function arguments.
                RasterFunctionArguments rasterFunctionArguments = rasterFunction.Arguments;

                // Get the list of names from the raster function arguments.
                IReadOnlyList <string> myRasterNames = rasterFunctionArguments.GetRasterNames();

                // Apply the first raster name and image service raster in the raster function arguments.
                rasterFunctionArguments.SetRaster(myRasterNames[0], imageServiceRaster);

                // Create a new raster based on the raster function.
                Raster raster = new Raster(rasterFunction);

                // Create a new raster layer from the raster.
                RasterLayer rasterLayer = new RasterLayer(raster);

                // Add the raster layer to the maps layer collection.
                myMap.Basemap.BaseLayers.Add(rasterLayer);

                // Assign the map to the map view.
                _myMapView.Map = myMap;

                // Get the service information (aka. metadata) about the image service raster.
                ArcGISImageServiceInfo arcGISImageServiceInfo = imageServiceRaster.ServiceInfo;

                // Zoom the map to the extent of the image service raster (which also the extent of the raster layer).
                await _myMapView.SetViewpointGeometryAsync(arcGISImageServiceInfo.FullExtent);
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
コード例 #5
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);
            }
        }