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);
            }
        }
Ejemplo n.º 2
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            Map streetMap = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile.
            string filepath = DataManager.GetDataFolder("d98b3e5293834c5f852f13c569930caa", "TrailBikeNetwork.shp");

            // Open the shapefile.
            ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

            // Read metadata about the shapefile and display it in the UI.
            _shapefileMetadata = myShapefile.Info;

            // Create a feature layer to display the shapefile.
            FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);

            // Zoom the map to the extent of the shapefile.
            _myMapView.SpatialReferenceChanged += async(s, e) => { await _myMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent); };

            // Add the feature layer to the map.
            streetMap.OperationalLayers.Add(newFeatureLayer);

            // Show the map in the MapView.
            _myMapView.Map = streetMap;
        }
Ejemplo n.º 3
0
        private async void Initialize()
        {
            try
            {
                // Create a new map with a streets basemap.
                Map map = new Map(Basemap.CreateStreetsVector());

                // Create the restaurants layer and add it to the map.
                FeatureLayer restaurantLayer = new FeatureLayer(_restaurantUri);
                map.OperationalLayers.Add(restaurantLayer);

                // Load the feature table for the restaurants layer.
                await restaurantLayer.FeatureTable.LoadAsync();

                // Open the custom style file.
                DictionarySymbolStyle restaurantStyle = await DictionarySymbolStyle.CreateFromFileAsync(_stylxPath);

                // Create the dictionary renderer with the style file and the field overrides.
                DictionaryRenderer dictRenderer = new DictionaryRenderer(restaurantStyle);

                // Set the restaurant layer renderer to the dictionary renderer.
                restaurantLayer.Renderer = dictRenderer;

                // Set the map's initial extent to that of the restaurants.
                map.InitialViewpoint = new Viewpoint(restaurantLayer.FullExtent);

                // Set the map to the map view.
                MyMapView.Map = map;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap
            Map streetMap = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile
            string filepath = GetShapefilePath();

            // Open the shapefile
            ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

            // Read metadata about the shapefile and display it in the UI
            _shapefileMetadata = myShapefile.Info;

            // Create a feature layer to display the shapefile
            FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);

            // Zoom the map to the extent of the shapefile
            _myMapView.SpatialReferenceChanged += async(s, e) =>
            {
                await _myMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent);
            };

            // Add the feature layer to the map
            streetMap.OperationalLayers.Add(newFeatureLayer);

            // Show the map in the MapView
            _myMapView.Map = streetMap;
        }
Ejemplo n.º 5
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            _myMapView.Map = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile.
            string filepath = DataManager.GetDataFolder("d98b3e5293834c5f852f13c569930caa", "Public_Art.shp");

            try
            {
                // Open the shapefile.
                ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

                // Create a feature layer to display the shapefile.
                FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);

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

                // Zoom the map to the extent of the shapefile.
                await _myMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent, 50);
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private void Initialize()
        {
            // Create a new Map with a vector streets basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create and set the map's initial view point.
            MapPoint initialLocation = new MapPoint(-12716000.00, 4170400.00, SpatialReferences.WebMercator);

            myMap.InitialViewpoint = new Viewpoint(initialLocation, 6000000);

            // Create the URI to the USA map service.
            Uri usaServiceUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");

            // Create a new ArcGISMapImageLayer that uses the service URI.
            ArcGISMapImageLayer usaMapImageLayer = new ArcGISMapImageLayer(usaServiceUri);

            // Add the layer to the map.
            myMap.OperationalLayers.Add(usaMapImageLayer);

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

            // Add a graphics overlay to show selected features.
            _selectedFeaturesOverlay = new GraphicsOverlay();
            _myMapView.GraphicsOverlays.Add(_selectedFeaturesOverlay);
        }
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map map = new Map(Basemap.CreateStreetsVector());

            // Get the file name for the local raster dataset.
            string filepath = DataManager.GetDataFolder("134d60f50e184e8fa56365f44e5ce3fb", "srtm-hillshade", "srtm.tiff");

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

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

            // Enable the apply renderer button when the layer loads.
            _applyHillshadeButton.Enabled = true;

            // Set the initial viewpoint to the raster's full extent.
            map.InitialViewpoint = new Viewpoint(_rasterLayer.FullExtent);

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

            // Add the map to the map view.
            _myMapView.Map = map;
        }
Ejemplo n.º 8
0
        private async void Initialize()
        {
            // Add event handler for when this sample is unloaded.
            Unloaded += SampleUnloaded;

            // Show a map with a streets basemap.
            MyMapView.Map = new Map(Basemap.CreateStreetsVector());

            // Subscribe to location changed events (to support zooming to current location).
            MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged;

            // Enable location display.
            MyMapView.LocationDisplay.IsEnabled = true;

            // Enable tap-for-info pattern on results.
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;

            // Initialize the LocatorTask with the provided service Uri.
            _geocoder = await LocatorTask.CreateAsync(_serviceUri);

            // Enable all controls now that the locator task is ready.
            MySearchBox.IsEnabled              = true;
            MyLocationBox.IsEnabled            = true;
            MySearchButton.IsEnabled           = true;
            MySearchRestrictedButton.IsEnabled = true;
        }
Ejemplo n.º 9
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap
            MyMapView.Map = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile
            string filepath = GetShapefilePath();

            try
            {
                // Open the shapefile
                ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

                // Create a feature layer to display the shapefile
                FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);

                // Add the feature layer to the map
                MyMapView.Map.OperationalLayers.Add(newFeatureLayer);

                // Zoom the map to the extent of the shapefile
                await MyMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent, 50);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map map = new Map(Basemap.CreateStreetsVector());

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

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

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

            // Enable the apply renderer button when the layer loads.
            _applyHillshadeButton.Enabled = 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;
        }
Ejemplo n.º 11
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            Map streetMap = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile.
            string filepath = DataManager.GetDataFolder("d98b3e5293834c5f852f13c569930caa", "TrailBikeNetwork.shp");

            try
            {
                // Open the shapefile.
                ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

                // Read metadata about the shapefile and display it in the UI.
                _shapefileMetadata = myShapefile.Info;

                // Create a feature layer to display the shapefile.
                _featureLayer = new FeatureLayer(myShapefile);

                // Zoom the map to the extent of the shapefile.
                _myMapView.SpatialReferenceChanged += MapView_SpatialReferenceChanged;

                // Add the feature layer to the map.
                streetMap.OperationalLayers.Add(_featureLayer);

                // Show the map in the MapView.
                _myMapView.Map = streetMap;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap
            Map streetMap = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile
            string filepath = GetShapefilePath();

            // Open the shapefile
            ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

            // Read metadata about the shapefile and display it in the UI
            ShapefileInfo fileInfo = myShapefile.Info;

            InfoPanel.DataContext = fileInfo;

            // Display the shapefile thumbnail in an image control
            ShapefileThumbnailImage.Source = await Esri.ArcGISRuntime.UI.RuntimeImageExtensions.ToImageSourceAsync(fileInfo.Thumbnail);

            // Create a feature layer to display the shapefile
            FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);
            await newFeatureLayer.LoadAsync();

            // Zoom the map to the extent of the shapefile
            MyMapView.SpatialReferenceChanged += async(s, e) =>
            {
                await MyMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent);
            };

            // Add the feature layer to the map
            streetMap.OperationalLayers.Add(newFeatureLayer);

            // Show the map in the MapView
            MyMapView.Map = streetMap;
        }
        private async void Initialize()
        {
            try
            {
                // Open the custom style file.
                _restaurantStyle = await DictionarySymbolStyle.CreateFromFileAsync(_stylxPath);

                // Create a new map with a streets basemap.
                Map map = new Map(Basemap.CreateStreetsVector());

                // Create the restaurants layer and add it to the map.
                FeatureLayer restaurantLayer = new FeatureLayer(_restaurantUri);
                map.OperationalLayers.Add(restaurantLayer);

                // Load the feature table for the restaurants layer.
                FeatureTable restaurantTable = restaurantLayer.FeatureTable;
                await restaurantTable.LoadAsync();

                // Set the map's initial extent to that of the restaurants.
                map.InitialViewpoint = new Viewpoint(restaurantLayer.FullExtent);

                // Set the map to the map view.
                _myMapView.Map = map;

                // Apply the custom dictionary to the restaurant feature layer.
                ApplyCustomDictionary();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 14
0
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map map = new Map(Basemap.CreateStreetsVector());

            // Get the file name for the local raster dataset.
            string filepath =
                DataManager.GetDataFolder("134d60f50e184e8fa56365f44e5ce3fb", "srtm-hillshade", "srtm.tiff");

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

            try
            {
                // Create and load a new raster layer to show the image.
                _rasterLayer = new RasterLayer(rasterFile);
                await _rasterLayer.LoadAsync();

                // Set up the settings controls.
                _settingsVC = new HillshadeSettingsController(_rasterLayer);

                // Set the initial viewpoint to the raster's full extent.
                map.InitialViewpoint = new Viewpoint(_rasterLayer.FullExtent);

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

                // Add the map to the map view.
                _myMapView.Map = map;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Ejemplo n.º 15
0
        private async void Initialize()
        {
            // Create a new Map with a vector streets basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create the URI to the Service Requests map service.
            Uri serviceRequestUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/MapServer");

            // Create a new ArcGISMapImageLayer that uses the service URI.
            ArcGISMapImageLayer serviceRequestsMapImageLayer = new ArcGISMapImageLayer(serviceRequestUri);

            // Load all sublayers and tables contained by the map image layer.
            await serviceRequestsMapImageLayer.LoadTablesAndLayersAsync();

            // Set the initial map extent to the extent of all service request features.
            Envelope requestsExtent = serviceRequestsMapImageLayer.FullExtent;

            myMap.InitialViewpoint = new Viewpoint(requestsExtent);

            // Add the layer to the map.
            myMap.OperationalLayers.Add(serviceRequestsMapImageLayer);

            // Get the service request comments table from the map image layer.
            ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0];

            // Create query parameters to get all non-null service request comment records (features) from the table.
            QueryParameters queryToGetNonNullComments = new QueryParameters
            {
                WhereClause = "requestid <> '' AND comments <> ''"
            };

            // Query the comments table to get the non-null records.
            FeatureQueryResult commentQueryResult = await commentsTable.QueryFeaturesAsync(queryToGetNonNullComments, QueryFeatureFields.LoadAll);

            // Show the records from the service request comments table in the UITableView control.
            foreach (ArcGISFeature commentFeature in commentQueryResult)
            {
                _serviceRequestComments.Add(commentFeature);
            }

            // Create the table view source that uses the list of features.
            ServiceRequestCommentsTableSource commentsTableSource = new ServiceRequestCommentsTableSource(_serviceRequestComments);

            // Handle a new selection in the table source.
            commentsTableSource.ServiceRequestCommentSelected += CommentsTableSource_ServiceRequestCommentSelected;

            // Assign the table view source to the table view control.
            _tableView.Source = commentsTableSource;

            // Create a graphics overlay to show selected features and add it to the map view.
            _selectedFeaturesOverlay = new GraphicsOverlay();
            _myMapView.GraphicsOverlays.Add(_selectedFeaturesOverlay);

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

            // Reload the table view data to refresh the display.
            _tableView.ReloadData();
        }
Ejemplo n.º 16
0
        private void Initialize()
        {
            // Create a map with 'Imagery with Labels' basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

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

            // Create a center point for the graphics.
            MapPoint centerPoint = new MapPoint(-117.195800, 34.056295, SpatialReferences.Wgs84);

            // Create an envelope from that center point.
            Envelope pointExtent = new Envelope(centerPoint, .5, .5);

            //get the four corners of the extent
            MapPoint location1 = new MapPoint(pointExtent.XMax, pointExtent.YMax);
            MapPoint location2 = new MapPoint(pointExtent.XMax, pointExtent.YMin);
            MapPoint location3 = new MapPoint(pointExtent.XMin, pointExtent.YMax);
            MapPoint location4 = new MapPoint(pointExtent.XMin, pointExtent.YMin);


            // Create a collection of points in the extent
            Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(Calculate(location1, location2, location3, location4), SpatialReferences.Wgs84);

            // Create overlay to where graphics are shown.
            _graphicsOverlay = new GraphicsOverlay();

            // Add points to the graphics overlay.
            foreach (MapPoint point in points)
            {
                // Create new graphic and add it to the overlay.
                _graphicsOverlay.Graphics.Add(new Graphic(point));
            }

            // Create symbol for points.
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol()
            {
                Color = System.Drawing.Color.Yellow,
                Size  = 30,
                Style = SimpleMarkerSymbolStyle.Square
            };

            // Create simple renderer with symbol.
            SimpleRenderer renderer = new SimpleRenderer(pointSymbol);

            // Set renderer to graphics overlay.
            _graphicsOverlay.Renderer = renderer;

            // Add created overlay to the MapView.
            MyMapView.GraphicsOverlays.Add(_graphicsOverlay);

            // Center the MapView on the points.
            MyMapView.SetViewpointGeometryAsync(pointExtent, 50);
        }
Ejemplo n.º 17
0
        private void Initialize()
        {
            // Define the route stop locations (points)
            MapPoint fromPoint = new MapPoint(-117.15494348793044, 32.706506537686927, SpatialReferences.Wgs84);
            MapPoint toPoint   = new MapPoint(-117.14905088669816, 32.735308180609138, SpatialReferences.Wgs84);

            // Create Stop objects with the points and add them to a list of stops
            Stop stop1 = new Stop(fromPoint);
            Stop stop2 = new Stop(toPoint);

            _routeStops = new List <Stop> {
                stop1, stop2
            };

            // Picture marker symbols: from = car, to = checkered flag
            PictureMarkerSymbol carSymbol  = new PictureMarkerSymbol(_carIconUri);
            PictureMarkerSymbol flagSymbol = new PictureMarkerSymbol(_checkedFlagIconUri);

            // Add a slight offset (pixels) to the picture symbols.
            carSymbol.OffsetX  = -carSymbol.Width / 2;
            carSymbol.OffsetY  = -carSymbol.Height / 2;
            flagSymbol.OffsetX = -flagSymbol.Width / 2;
            flagSymbol.OffsetY = -flagSymbol.Height / 2;

            // Create graphics for the stops
            Graphic fromGraphic = new Graphic(fromPoint, carSymbol)
            {
                ZIndex = 1
            };
            Graphic toGraphic = new Graphic(toPoint, flagSymbol)
            {
                ZIndex = 1
            };

            // Create the graphics overlay and add the stop graphics
            _routeGraphicsOverlay = new GraphicsOverlay();
            _routeGraphicsOverlay.Graphics.Add(fromGraphic);
            _routeGraphicsOverlay.Graphics.Add(toGraphic);

            // Get an Envelope that covers the area of the stops (and a little more)
            Envelope        routeStopsExtent = new Envelope(fromPoint, toPoint);
            EnvelopeBuilder envBuilder       = new EnvelopeBuilder(routeStopsExtent);

            envBuilder.Expand(1.5);

            // Create a new viewpoint apply it to the map view when the spatial reference changes
            Viewpoint sanDiegoViewpoint = new Viewpoint(envBuilder.ToGeometry());

            MyMapView.SpatialReferenceChanged += (s, e) => MyMapView.SetViewpoint(sanDiegoViewpoint);

            // Add a new Map and the graphics overlay to the map view
            MyMapView.Map = new Map(Basemap.CreateStreetsVector());
            MyMapView.GraphicsOverlays.Add(_routeGraphicsOverlay);
        }
Ejemplo n.º 18
0
        private async void Initialize()
        {
            // Create a new Map with a vector streets basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create the URI to the Service Requests map service.
            Uri serviceRequestUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/MapServer");

            // Create a new ArcGISMapImageLayer that uses the service URI.
            ArcGISMapImageLayer serviceRequestsMapImageLayer = new ArcGISMapImageLayer(serviceRequestUri);

            try
            {
                // Load all sublayers and tables contained by the map image layer.
                await serviceRequestsMapImageLayer.LoadTablesAndLayersAsync();

                // Set the initial map extent to the extent of all service request features.
                Envelope requestsExtent = serviceRequestsMapImageLayer.FullExtent;
                myMap.InitialViewpoint = new Viewpoint(requestsExtent);

                // Add the layer to the map.
                myMap.OperationalLayers.Add(serviceRequestsMapImageLayer);

                // Get the service request comments table from the map image layer.
                ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0];

                // Create query parameters to get all non-null service request comment records (features) from the table.
                QueryParameters queryToGetNonNullComments = new QueryParameters
                {
                    WhereClause = "requestid <> '' AND comments <> ''"
                };

                // Query the comments table to get the non-null records.
                FeatureQueryResult commentQueryResult = await commentsTable.QueryFeaturesAsync(queryToGetNonNullComments, QueryFeatureFields.LoadAll);

                // Show the records from the service request comments table in the list view control.
                CommentsListBox.ItemsSource = commentQueryResult.ToList();

                // Create a graphics overlay to show selected features and add it to the map view.
                _selectedFeaturesOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(_selectedFeaturesOverlay);

                // Assign the map to the MapView.
                MyMapView.Map = myMap;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
Ejemplo n.º 19
0
        private void Initialize()
        {
            // Create a new Map with the world streets vector basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create feature table using the world cities URI.
            _worldCitiesTable = new ServiceFeatureTable(_worldCitiesServiceUri);

            // Create a new feature layer to display features in the world cities table.
            FeatureLayer worldCitiesLayer = new FeatureLayer(_worldCitiesTable);

            // Add the world cities layer to the map.
            myMap.OperationalLayers.Add(worldCitiesLayer);

            // Assign the map to the MapView.
            _myMapView.Map = myMap;
        }
Ejemplo n.º 20
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());
            }
        }
Ejemplo n.º 21
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap
            _myMapView.Map = new Map(Basemap.CreateStreetsVector());

            // Get the path to the downloaded shapefile
            string filepath = await GetShapefilePath();

            // Open the shapefile
            ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(filepath);

            // Create a feature layer to display the shapefile
            FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile);

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

            // Zoom the map to the extent of the shapefile
            await _myMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent);
        }
Ejemplo n.º 22
0
        private async void Initialize()
        {
            // Create the map with a vector street basemap
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create the feature table from the service URL
            _myFeatureTable = new ServiceFeatureTable(_usaCitiesSource);

            // Create the feature layer from the table
            FeatureLayer myFeatureLayer = new FeatureLayer(_myFeatureTable);

            // Add the feature layer to the map
            myMap.OperationalLayers.Add(myFeatureLayer);

            // Wait for the feature layer to load
            await myFeatureLayer.LoadAsync();

            // Set the map initial extent to the extent of the feature layer
            myMap.InitialViewpoint = new Viewpoint(myFeatureLayer.FullExtent);

            // Add the map to the MapView
            MyMapView.Map = myMap;
        }
Ejemplo n.º 23
0
        private static Map CreateMap()
        {
            if (File.Exists("map.json"))
            {
                var savedMap = Map.FromJson(File.ReadAllText("map.json"));
                savedMap.InitialViewpoint = new Viewpoint(51.05011, -114.08, 4000);
                return(savedMap);
            }
            var map = new Map(Basemap.CreateStreetsVector())
            {
                InitialViewpoint = new Viewpoint(51.05011, -114.08, 4000)
            };
            var data = new FeatureCollection();

            data.Tables.Add(new FeatureCollectionTable(
                                new Field[] { new Field(FieldType.Text, "Text", null, 50) },
                                GeometryType.Point, SpatialReferences.Wgs84)
            {
                Renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 20))
            });
            map.OperationalLayers.Add(new FeatureCollectionLayer(data));
            return(map);
        }
Ejemplo n.º 24
0
        public void ChangeBasemap(string basemap)
        {
            // Apply the selected basemap to the map
            switch (basemap)
            {
            case "Topographic":
                // Set the basemap to Topographic
                _map.Basemap = Basemap.CreateTopographic();
                break;

            case "Topographic Vector":
                // Set the basemap to Topographic (vector)
                _map.Basemap = Basemap.CreateTopographicVector();
                break;

            case "Streets":
                // Set the basemap to Streets
                _map.Basemap = Basemap.CreateStreets();
                break;

            case "Streets Vector":
                // Set the basemap to Streets (vector)
                _map.Basemap = Basemap.CreateStreetsVector();
                break;

            case "Imagery":
                // Set the basemap to Imagery
                _map.Basemap = Basemap.CreateImagery();
                break;

            case "Oceans":
                // Set the basemap to Oceans
                _map.Basemap = Basemap.CreateOceans();
                break;
            }
        }
Ejemplo n.º 25
0
        public async void ChangeBasemap(string basemap)
        {
            // Apply the selected basemap to the map
            switch (basemap)
            {
            case "Topographic":
                // Set the basemap to Topographic
                _map.Basemap = Basemap.CreateTopographic();
                break;

            case "Topographic Vector":
                // Set the basemap to Topographic (vector)
                _map.Basemap = Basemap.CreateTopographicVector();
                break;

            case "Streets":
                // Set the basemap to Streets
                _map.Basemap = Basemap.CreateStreets();
                break;

            case "Streets Vector":
                // Set the basemap to Streets (vector)
                _map.Basemap = Basemap.CreateStreetsVector();
                break;

            case "Imagery":
                // Set the basemap to Imagery
                _map.Basemap = Basemap.CreateImagery();
                break;

            case "Oceans":
                // Set the basemap to Oceans
                _map.Basemap = Basemap.CreateOceans();
                break;

            case "USGS National Map":
                // Set the basemap to USGS National Map by opening it from ArcGIS Online
                var itemID = "809d37b42ca340a48def914df43e2c31";

                // Connect to ArcGIS Online
                ArcGISPortal agsOnline = await ArcGISPortal.CreateAsync();

                // Get the USGS webmap item
                PortalItem usgsMapItem = await PortalItem.CreateAsync(agsOnline, itemID);

                // Create a new basemap using the item
                _map.Basemap = new Basemap(usgsMapItem);
                break;

            case "World Globe 1812":
                // Create a URI that points to a map service to use in the basemap
                var uri = new Uri("https://tiles.arcgis.com/tiles/IEuSomXfi6iB7a25/arcgis/rest/services/World_Globe_1812/MapServer");

                // Create an ArcGISTiledLayer from the URI
                ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(uri);

                // Create a basemap from the layer and assign it to the map
                _map.Basemap = new Basemap(baseLayer);
                break;
            }
        }
Ejemplo n.º 26
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);
            }
        }
        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);
            }
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 29
0
        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);
            }
        }