private void LoadWorkbench() { MyViewPoint p = ViewPointWork.LoadPoint(); MyMapView.SetViewpointCenterAsync(new MapPoint(p.X, p.Y, new Esri.ArcGISRuntime.Geometry.SpatialReference(p.Wkid))); MyMapView.SetViewpointScaleAsync(p.Scale); }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error configuring geocoder").ShowAsync(); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
private async void Initialize() { // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
public void Load_ImageryWithLabels_Layer() { MainViewModel.SetBBox(); MyMapView.Map = new Map(Basemap.CreateImageryWithLabels()); MyMapView.SetViewpointCenterAsync(MainViewModel.CenterPoint); MainViewModel.SetBBox(); }
public void Load_OpenStreetMap() { MainViewModel.SetBBox(); MyMapView.Map = new Map(Basemap.CreateOpenStreetMap()); MyMapView.SetViewpointCenterAsync(MainViewModel.CenterPoint); MainViewModel.SetBBox(); }
private async void Initialize() { // Create new map with the dark gray canvas basemap. Map myMap = new Map(Basemap.CreateDarkGrayCanvasVector()); // 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://gis.ngdc.noaa.gov/arcgis/rest/services/bag_hillshades/ImageServer"); // Create new image service raster from the Uri. ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(myUri); // Load the image service raster. await myImageServiceRaster.LoadAsync(); // Create a new raster layer from the image service raster. RasterLayer myRasterLayer = new RasterLayer(myImageServiceRaster); // Add the raster layer to the maps layer collection. myMap.Basemap.BaseLayers.Add(myRasterLayer); // Assign the map to the map view. MyMapView.Map = myMap; // zoom in to the San Francisco Bay. await MyMapView.SetViewpointCenterAsync(new MapPoint(-13643095.660131, 4550009.846004, SpatialReferences.WebMercator), 100000); }
private async void Initialize() { // Create new Map with basemap. Map myMap = new Map(BasemapStyle.ArcGISImagery); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await new MessageDialog(e.ToString(), "Error configuring geocoder").ShowAsync(); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
private void Initialize() { // Configure the basemap MyMapView.Map = new Map(Basemap.CreateTopographic()); // Create the graphics overlay and set the selection color _graphicsOverlay = new GraphicsOverlay(); // Add the overlay to the MapView MyMapView.GraphicsOverlays.Add(_graphicsOverlay); // Create the point collection that defines the polygon PointCollection polygonPoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-5991501.677830, 5599295.131468), new MapPoint(-6928550.398185, 2087936.739807), new MapPoint(-3149463.800709, 1840803.011362), new MapPoint(-1563689.043184, 3714900.452072), new MapPoint(-3180355.516764, 5619889.608838) }; // Create the polygon Polygon polygonGeometry = new Polygon(polygonPoints); // Define and apply the symbology SimpleLineSymbol polygonOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Windows.UI.Colors.Green, 2); SimpleFillSymbol polygonFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Windows.UI.Colors.Green, polygonOutlineSymbol); // Create the graphic and add it to the graphics overlay _polygonGraphic = new Graphic(polygonGeometry, polygonFillSymbol); _graphicsOverlay.Graphics.Add(_polygonGraphic); // Create the graphics and symbology for the tapped point, the nearest vertex, and the nearest coordinate SimpleMarkerSymbol tappedLocationSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, Windows.UI.Colors.Orange, 15); SimpleMarkerSymbol nearestCoordinateSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Windows.UI.Colors.Red, 10); SimpleMarkerSymbol nearestVertexSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Windows.UI.Colors.Blue, 15); _nearestCoordinateGraphic = new Graphic { Symbol = nearestCoordinateSymbol }; _tappedLocationGraphic = new Graphic { Symbol = tappedLocationSymbol }; _nearestVertexGraphic = new Graphic { Symbol = nearestVertexSymbol }; _graphicsOverlay.Graphics.Add(_tappedLocationGraphic); _graphicsOverlay.Graphics.Add(_nearestVertexGraphic); _graphicsOverlay.Graphics.Add(_nearestCoordinateGraphic); // Listen for taps; the spatial relationships will be updated in the handler MyMapView.GeoViewTapped += MapViewTapped; // Center the map on the polygon // Create the point that defines the point graphic MapPoint centerPoint = new MapPoint(-4487263.495911, 3699176.480377, SpatialReferences.WebMercator); MyMapView.SetViewpointCenterAsync(centerPoint, 200000000); }
// Handle a new selected comment record in the table view. private async void CommentsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // Get the selected comment feature. If there is no selection, return. ArcGISFeature selectedComment = e.AddedItems[0] as ArcGISFeature; if (selectedComment == null) { return; } // Get the map image layer that contains the service request sublayer and the service request comments table. ArcGISMapImageLayer serviceRequestsMapImageLayer = MyMapView.Map.OperationalLayers[0] as ArcGISMapImageLayer; // Get the (non-spatial) table that contains the service request comments. ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0]; // Get the relationship that defines related service request features for features in the comments table (this is the first and only relationship). RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault(); // Create query parameters to get the related service request for features in the comments table. RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo) { ReturnGeometry = true }; // Query the comments table to get the related service request feature for the selected comment. IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams); // Get the first result. RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault(); // Get the first feature from the result. If it's null, warn the user and return. ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature; if (serviceRequestFeature == null) { MessageBox.Show("Related feature not found.", "No Feature"); return; } // Load the related service request feature (so its geometry is available). await serviceRequestFeature.LoadAsync(); // Get the service request geometry (point). MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint; // Create a cyan marker symbol to display the related feature. Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Cyan, 14); // Create a graphic using the service request point and marker symbol. Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol); // Add the graphic to the graphics overlay and zoom the map view to its extent. _selectedFeaturesOverlay.Graphics.Add(requestGraphic); await MyMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000); }
private async void Geocoording_Click(object sender, RoutedEventArgs e) { //マップが準備できていなければ処理を行わない if (!isMapReady) { return; } //住所検索用のパラメータを作成 var geocodeParams = new GeocodeParameters { MaxResults = 5, OutputSpatialReference = SpatialReferences.WebMercator, CountryCode = "Japan", OutputLanguage = new System.Globalization.CultureInfo("ja-JP"), }; try { //住所の検索 var resultCandidates = await onlineLocatorTask.GeocodeAsync(addressTextBox.Text, geocodeParams); //住所検索結果に対する処理(1つ以上候補が返されていれば処理を実行) if (resultCandidates != null && resultCandidates.Count > 0) { //現在の結果を消去 geocodeResultGraphicsOverlay.Graphics.Clear(); //常に最初の候補を採用 var candidate = resultCandidates.FirstOrDefault(); //最初の候補からグラフィックを作成 Graphic locatedPoint = new Graphic() { Geometry = candidate.DisplayLocation, }; //住所検索結果表示用のグラフィックスオーバーレイにグラフィックを追加 geocodeResultGraphicsOverlay.Graphics.Add(locatedPoint); //追加したグラフィックの周辺に地図を拡大 await MyMapView.SetViewpointCenterAsync((MapPoint)locatedPoint.Geometry, 36112); } //候補が一つも見つからない場合の処理 else { var message = new MessageDialog("住所検索:該当する場所がみつかりません。"); await message.ShowAsync(); } } //エラーが発生した場合の処理 catch (Exception ex) { var message = new MessageDialog(string.Format("住所検索:{0}", ex.Message)); await message.ShowAsync(); } }
public Window1() { InitializeComponent(); //最大化窗体 this.WindowState = WindowState.Maximized; //初始地图中心 MyMapView.SetViewpointCenterAsync(new MapPoint(11800000, 4500000, SpatialReferences.WebMercator), 3e7); Initialize(); }
private async void OnViewpointsClicked(object sender, EventArgs e) { try { // Show sheet and get title from the selection string selectedMapTitle = await((Page)Parent).DisplayActionSheet("Select viewpoint", "Cancel", null, titles); // If selected cancel do nothing if (selectedMapTitle == "Cancel") { return; } switch (selectedMapTitle) { case "Geometry": // Set Viewpoint using Redlands envelope defined above and a padding of 20 await MyMapView.SetViewpointGeometryAsync(RedlandsEnvelope, 20); break; case "Center & Scale": // Set Viewpoint so that it is centered on the London coordinates defined above await MyMapView.SetViewpointCenterAsync(LondonCoords); // Set the Viewpoint scale to match the specified scale await MyMapView.SetViewpointScaleAsync(LondonScale); break; case "Animate": // Navigate to full extent of the first baselayer before animating to specified geometry await MyMapView.SetViewpointAsync( new Viewpoint(MyMapView.Map.Basemap.BaseLayers.First().FullExtent)); // Create a new Viewpoint using the specified geometry Viewpoint viewpoint = new Viewpoint(EdinburghEnvelope); // Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5)); break; default: break; } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateTopographic()); // Provide Map to the MapView MyMapView.Map = myMap; // Create geometry for the center of the map MapPoint centerGeometry = new MapPoint(-13549402.587055, 4397264.96879385, SpatialReference.Create(3857)); // Set the map's viewpoint to highlight the desired content await MyMapView.SetViewpointCenterAsync(centerGeometry); await MyMapView.SetViewpointScaleAsync(201555.279); // Get the path to the geodatabase string geodbFilePath = await GetPreparedFilePath(_geodatabaseName, _geodatabaseId); // Load the geodatabase from local storage Geodatabase baseGeodatabase = await Geodatabase.OpenAsync(geodbFilePath); // Get the path to the symbol dictionary string symbolFilepath = await GetPreparedFilePath(_symbolDefName, _symbolDefId); // Load the symbol dictionary from local storage // Note that the type of the symbol definition must be explicitly provided along with the file name DictionarySymbolStyle symbolStyle = await DictionarySymbolStyle.OpenAsync("mil2525d", symbolFilepath); // Add geodatabase features to the map, using the defined symbology foreach (FeatureTable table in baseGeodatabase.GeodatabaseFeatureTables) { // Load the table await table.LoadAsync(); // Create the feature layer from the table FeatureLayer myLayer = new FeatureLayer(table); // Load the layer await myLayer.LoadAsync(); // Create a Dictionary Renderer using the DictionarySymbolStyle DictionaryRenderer dictRenderer = new DictionaryRenderer(symbolStyle); // Apply the dictionary renderer to the layer myLayer.Renderer = dictRenderer; // Add the layer to the map myMap.OperationalLayers.Add(myLayer); } }
/// <summary> /// this method helps to navigate through the basemap as a location in the listbox is made /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void GoTimeListbox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { double x = 1.0; double y = 1.0; int index = GoTimeListbox.SelectedIndex; switch (index) { case 0: //Canada x = -113.712785; y = 54.6985831; break; case 1: //Thailand x = 96.9946297; y = 13.0003408; break; case 2: // Iceland x = -23.7277777; y = 64.7967723; break; case 3: // India x = 73.7293199; y = 20.7505273; break; case 4: // Rock of Gibraltor x = -5.3504789; y = 36.1440926; break; default: //Canada x = 54.6985831; y = -113.712785; break; } MapPoint point = new MapPoint(x, y, SpatialReference.Create(4326)); await MyMapView.SetViewpointCenterAsync(point); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void OnButtonClick(object sender, RoutedEventArgs e) { try { // Get .Content from the selected item Button myButton = (Button)sender; string selectedMapTitle = myButton.Content.ToString(); switch (selectedMapTitle) { case "Geometry": // Set Viewpoint using Redlands envelope defined above and a padding of 20 await MyMapView.SetViewpointGeometryAsync(_redlandsEnvelope, 20); break; case "Center and Scale": // Set Viewpoint so that it is centered on the London coordinates defined above await MyMapView.SetViewpointCenterAsync(_londonCoords); // Set the Viewpoint scale to match the specified scale await MyMapView.SetViewpointScaleAsync(_londonScale); break; case "Animate": // Navigate to full extent of the first baselayer before animating to specified geometry await MyMapView.SetViewpointAsync( new Viewpoint(MyMapView.Map.Basemap.BaseLayers.First().FullExtent)); // Create a new Viewpoint using the specified geometry Viewpoint viewpoint = new Viewpoint(_edinburghEnvelope); // Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5)); break; default: break; } } catch (Exception ex) { await new MessageDialog2(ex.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { // Create a map with a light gray canvas basemap. Map sampleMap = new Map(Basemap.CreateLightGrayCanvas()); // Assign the map to the MapView. MyMapView.Map = sampleMap; // Define the URL string for the feature layer. string layerUrl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_115th_Congressional_Districts/FeatureServer/0"; // Create a service feature table from the URL. ServiceFeatureTable featureTable = new ServiceFeatureTable(new Uri(layerUrl)); // Create a feature layer from the service feature table. FeatureLayer districtFeatureLabel = new FeatureLayer(featureTable); // Add the feature layer to the operations layers collection of the map. sampleMap.OperationalLayers.Add(districtFeatureLabel); try { // Load the feature layer - this way we can obtain it's extent. await districtFeatureLabel.LoadAsync(); // Zoom the map view to the extent of the feature layer. await MyMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000); // Create a label definition from the JSON string. LabelDefinition redLabelDefinition = LabelDefinition.FromJson(RedLabelJson); LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(BlueLabelJson); // Add the label definition to the feature layer's label definition collection. districtFeatureLabel.LabelDefinitions.Add(redLabelDefinition); districtFeatureLabel.LabelDefinitions.Add(blueLabelDefinition); // Enable the visibility of labels to be seen. districtFeatureLabel.LabelsEnabled = true; } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void Initialize() { // Create a map with a light gray canvas basemap. Map sampleMap = new Map(Basemap.CreateLightGrayCanvas()); // Assign the map to the MapView. MyMapView.Map = sampleMap; // Define the URL string for the feature layer. string layerUrl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_115th_Congressional_Districts/FeatureServer/0"; // Create a service feature table from the URL. ServiceFeatureTable featureTable = new ServiceFeatureTable(new Uri(layerUrl)); // Create a feature layer from the service feature table. FeatureLayer districtFeatureLabel = new FeatureLayer(featureTable); // Add the feature layer to the operations layers collection of the map. sampleMap.OperationalLayers.Add(districtFeatureLabel); try { // Load the feature layer - this way we can obtain it's extent. await districtFeatureLabel.LoadAsync(); // Zoom the map view to the extent of the feature layer. await MyMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000); // create label definitions for each party. LabelDefinition republicanLabelDefinition = MakeLabelDefinition("Republican", Color.Red); LabelDefinition democratLabelDefinition = MakeLabelDefinition("Democrat", Color.Blue); // Add the label definition to the feature layer's label definition collection. districtFeatureLabel.LabelDefinitions.Add(republicanLabelDefinition); districtFeatureLabel.LabelDefinitions.Add(democratLabelDefinition); // Enable the visibility of labels to be seen. districtFeatureLabel.LabelsEnabled = true; } catch (Exception ex) { await new MessageDialog2(ex.Message, "Error").ShowAsync(); } }
private void Initialize() { // Set up the map view with a basemap. MyMapView.Map = new Map(Basemap.CreateImageryWithLabels()); // Configure the UI options. gridTypePicker.ItemsSource = new[] { "LatLong", "MGRS", "UTM", "USNG" }; var colorItemsSource = new[] { "Red", "Green", "Blue", "White", "Purple" }; gridColorPicker.ItemsSource = colorItemsSource; labelColorPicker.ItemsSource = colorItemsSource; haloColorPicker.ItemsSource = colorItemsSource; labelPositionPicker.ItemsSource = Enum.GetNames(typeof(GridLabelPosition)); labelFormatPicker.ItemsSource = Enum.GetNames(typeof(LatitudeLongitudeGridLabelFormat)); foreach (var combo in new[] { gridTypePicker, gridColorPicker, labelColorPicker, labelPositionPicker, labelFormatPicker }) { combo.SelectedIndex = 0; } // Update the halo color to have a good default. haloColorPicker.SelectedIndex = 3; // Handle grid type changes so that the format option can be disabled for non-latlong grids. gridTypePicker.SelectedIndexChanged += (o, e) => { labelFormatPicker.IsEnabled = gridTypePicker.SelectedItem.ToString() == "LatLong"; }; // Subscribe to the button click event. applySettingsButton.Clicked += ApplySettingsButton_Clicked; // Enable the action button. applySettingsButton.IsEnabled = true; // Zoom to a default scale that will show the grid labels if they are enabled. MyMapView.SetViewpointCenterAsync( new MapPoint(-7702852.905619, 6217972.345771, SpatialReferences.WebMercator), 23227); // Apply default settings. ApplySettingsButton_Clicked(this, null); }
private async void OnButtonClick(object sender, RoutedEventArgs e) { // Get content from the selected item Button myButton = sender as Button; switch (myButton.Content.ToString()) { case "Geometry": // Set Viewpoint using Redlands envelope defined above and a padding of 20 await MyMapView.SetViewpointGeometryAsync(_redlandsEnvelope, 20); break; case "Center and Scale": // Set Viewpoint so that it is centered on the London coordinates defined above await MyMapView.SetViewpointCenterAsync(_londonCoords); // Set the Viewpoint scale to match the specified scale await MyMapView.SetViewpointScaleAsync(_londonScale); break; case "Animate": // Navigate to full extent of the first baselayer before animating to specified geometry await MyMapView.SetViewpointAsync( new Viewpoint(Basemap.FullExtent)); // Create a new Viewpoint using the specified geometry var viewpoint = new Viewpoint(_edinburghEnvelope); // Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5)); break; default: break; } }
private void Initialize() { // Set up the map view with a basemap. MyMapView.Map = new Map(Basemap.CreateImageryWithLabelsVector()); // Configure the UI options. GridTypeCombo.ItemsSource = new[] { "LatLong", "MGRS", "UTM", "USNG" }; var colorItemsSource = new[] { Colors.Red, Colors.Green, Colors.Blue, Colors.White, Colors.Purple }; GridColorCombo.ItemsSource = colorItemsSource; LabelColorCombo.ItemsSource = colorItemsSource; HaloColorCombo.ItemsSource = colorItemsSource; LabelPositionCombo.ItemsSource = Enum.GetNames(typeof(GridLabelPosition)); LabelFormatCombo.ItemsSource = Enum.GetNames(typeof(LatitudeLongitudeGridLabelFormat)); foreach (var combo in new[] { GridTypeCombo, GridColorCombo, LabelColorCombo, HaloColorCombo, LabelPositionCombo, LabelFormatCombo }) { combo.SelectedIndex = 0; } // Update the halo color so it isn't the same as the text color. HaloColorCombo.SelectedIndex = 3; // Subscribe to change events so the label format combo can be disabled as necessary. GridTypeCombo.SelectionChanged += (o, e) => { LabelFormatCombo.IsEnabled = GridTypeCombo.SelectedItem.ToString() == "LatLong"; }; // Subscribe to the button click event. ApplySettingsButton.Click += ApplySettingsButton_Click; // Enable the action button. ApplySettingsButton.IsEnabled = true; // Zoom to a default scale that will show the grid labels if they are enabled. MyMapView.SetViewpointCenterAsync( new MapPoint(-7702852.905619, 6217972.345771, SpatialReferences.WebMercator), 23227); // Apply default settings. ApplySettingsButton_Click(this, null); }
private void Initialize() { // Create the map with streets basemap. MyMapView.Map = new Map(BasemapStyle.ArcGISStreets); // Create the feature table, referring to the Damage Assessment feature service. _damageFeatureTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl)); // Create a feature layer to visualize the features in the table. FeatureLayer damageLayer = new FeatureLayer(_damageFeatureTable); // Add the layer to the map. MyMapView.Map.OperationalLayers.Add(damageLayer); // Listen for user taps on the map - this will select the feature. MyMapView.GeoViewTapped += MapView_Tapped; // Zoom to the United States. MyMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7); }
private void Initialize() { // Set up the map view with a basemap. MyMapView.Map = new Map(Basemap.CreateImageryWithLabelsVector()); // Configure the UI options. gridTypeCombo.ItemsSource = new[] { "LatLong", "MGRS", "UTM", "USNG" }; string[] colorItemsSource = { "Red", "Green", "Blue", "White", "Purple" }; gridColorCombo.ItemsSource = colorItemsSource; labelColorCombo.ItemsSource = colorItemsSource; haloColorCombo.ItemsSource = colorItemsSource; labelPositionCombo.ItemsSource = Enum.GetNames(typeof(GridLabelPosition)); labelFormatCombo.ItemsSource = Enum.GetNames(typeof(LatitudeLongitudeGridLabelFormat)); foreach (ComboBox combo in new[] { gridTypeCombo, gridColorCombo, labelColorCombo, labelPositionCombo, labelFormatCombo }) { combo.SelectedIndex = 0; } // Apply a good default halo color selection. haloColorCombo.SelectedIndex = 3; // Subscribe to grid type change events in order to disable the format change option when it doesn't apply. gridTypeCombo.SelectionChanged += (o, e) => { labelFormatCombo.IsEnabled = gridTypeCombo.SelectedItem.ToString() == "LatLong"; }; // Subscribe to the button click event. applySettingsButton.Click += ApplySettingsButton_Click; // Enable the action button. applySettingsButton.IsEnabled = true; // Zoom to a default scale that will show the grid labels if they are enabled. MyMapView.SetViewpointCenterAsync( new MapPoint(-7702852.905619, 6217972.345771, SpatialReferences.WebMercator), 23227); // Apply default settings. ApplySettingsButton_Click(this, null); }
private void Initialize() { // Create new map with the dark gray canvas basemap. Map myMap = new Map(BasemapStyle.ArcGISDarkGray); // Create a Uri to the image service raster. Uri myUri = new Uri("https://gis.ngdc.noaa.gov/arcgis/rest/services/bag_hillshades/ImageServer"); // Create new image service raster from the Uri. ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(myUri); // Create a new raster layer from the image service raster. RasterLayer myRasterLayer = new RasterLayer(myImageServiceRaster); // Add the raster layer to the maps layer collection. myMap.OperationalLayers.Add(myRasterLayer); // Assign the map to the map view. MyMapView.Map = myMap; // Zoom in to the San Francisco Bay. MyMapView.SetViewpointCenterAsync(new MapPoint(-13643095.660131, 4550009.846004, SpatialReferences.WebMercator), 100000); }
private void Initialize() { // Create the map with streets basemap. MyMapView.Map = new Map(Basemap.CreateStreets()); // Create the feature table, referring to the Damage Assessment feature service. ServiceFeatureTable damageTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl)); // When the table loads, use it to discover the domain of the typdamage field. damageTable.Loaded += DamageTable_Loaded; // Create a feature layer to visualize the features in the table. _damageLayer = new FeatureLayer(damageTable); // Add the layer to the map. MyMapView.Map.OperationalLayers.Add(_damageLayer); // Listen for user taps on the map - this will select the feature. MyMapView.GeoViewTapped += MapView_Tapped; // Zoom to the United States. MyMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7); }
private async void InitializeMap() { string geoPackagePath = GetOfflinePackagePath(@"full.gpkg"); try { //MyMapView.Map = new Map(BasemapType.OpenStreetMap, 0, 0, 10); var tileInfo = FGTiltInfoFactory.GetOpenStreetMapTileInfo(); var center = new MapPoint(12886578.9273218, -3753475.38812722, new SpatialReference(3857)); var extend = new Envelope(center, 100000000.0, 100000000.0); var aerial = new FGBaseMapTiledLayer( tileInfo, extend ); var basemap = new Basemap(aerial); MyMapView.Map = new Map(basemap); await MyMapView.SetViewpointCenterAsync(center, ScaleByZoomLevel(16)); MyMapView.ViewpointChanged += ViewpointChangedHandler; MyMapView.GeoViewTapped += GeoViewTappedHandler; // Open the GeoPackage this.MyGeoPackage = await GeoPackage.OpenAsync(geoPackagePath); //LoadByFeatureCollectionLayer(); LoadByFeatureLayer(); //SetViewpointBasedOnOperationalLayers(); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void CreateNewFeatureCollection() { // Create the schema for a points table (one text field to contain a name attribute) List <Field> pointFields = new List <Field>(); Field placeField = new Field(FieldType.Text, "Place", "Place Name", 50); pointFields.Add(placeField); // Create the schema for a lines table (one text field to contain a name attribute) List <Field> lineFields = new List <Field>(); Field boundaryField = new Field(FieldType.Text, "Boundary", "Boundary Name", 50); lineFields.Add(boundaryField); // Create the schema for a polygon table (one text field to contain a name attribute) List <Field> polyFields = new List <Field>(); Field areaField = new Field(FieldType.Text, "AreaName", "Area Name", 50); polyFields.Add(areaField); // Instantiate FeatureCollectionTables with schema and geometry type FeatureCollectionTable pointsTable = new FeatureCollectionTable(pointFields, GeometryType.Point, SpatialReferences.Wgs84); FeatureCollectionTable linesTable = new FeatureCollectionTable(lineFields, GeometryType.Polyline, SpatialReferences.Wgs84); FeatureCollectionTable polysTable = new FeatureCollectionTable(polyFields, GeometryType.Polygon, SpatialReferences.Wgs84); // Set rendering for each table pointsTable.Renderer = CreateRenderer(GeometryType.Point); linesTable.Renderer = CreateRenderer(GeometryType.Polyline); polysTable.Renderer = CreateRenderer(GeometryType.Polygon); // Create a new point feature, provide geometry and attribute values Feature pointFeature = pointsTable.CreateFeature(); pointFeature.SetAttributeValue(placeField, "Current location"); MapPoint point1 = new MapPoint(-79.497238, 8.849289, SpatialReferences.Wgs84); pointFeature.Geometry = point1; // Create a new line feature, provide geometry and attribute values Feature lineFeature = linesTable.CreateFeature(); lineFeature.SetAttributeValue(boundaryField, "AManAPlanACanalPanama"); MapPoint point2 = new MapPoint(-80.035568, 9.432302, SpatialReferences.Wgs84); Polyline line = new Polyline(new MapPoint[] { point1, point2 }); lineFeature.Geometry = line; // Create a new polygon feature, provide geometry and attribute values Feature polyFeature = polysTable.CreateFeature(); polyFeature.SetAttributeValue(areaField, "Restricted area"); MapPoint point3 = new MapPoint(-79.337936, 8.638903, SpatialReferences.Wgs84); MapPoint point4 = new MapPoint(-79.11409, 8.895422, SpatialReferences.Wgs84); Polygon poly = new Polygon(new MapPoint[] { point1, point3, point4 }); polyFeature.Geometry = poly; try { // Add the new features to the appropriate feature collection table await pointsTable.AddFeatureAsync(pointFeature); await linesTable.AddFeatureAsync(lineFeature); await polysTable.AddFeatureAsync(polyFeature); // Create a feature collection and add the feature collection tables FeatureCollection featuresCollection = new FeatureCollection(); featuresCollection.Tables.Add(pointsTable); featuresCollection.Tables.Add(linesTable); featuresCollection.Tables.Add(polysTable); // Create a FeatureCollectionLayer FeatureCollectionLayer collectionLayer = new FeatureCollectionLayer(featuresCollection); // When the layer loads, zoom the map centered on the feature collection await collectionLayer.LoadAsync(); await MyMapView.SetViewpointCenterAsync(collectionLayer.FullExtent.GetCenter(), 1000000); // Add the layer to the Map's Operational Layers collection MyMapView.Map.OperationalLayers.Add(collectionLayer); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void Initialize() { // Create a map with a light gray canvas basemap. Map sampleMap = new Map(Basemap.CreateLightGrayCanvas()); // Assign the map to the MapView. MyMapView.Map = sampleMap; // Define the URL string for the feature layer. string layerUrl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_115th_Congressional_Districts/FeatureServer/0"; // Create a service feature table from the URL. ServiceFeatureTable featureTable = new ServiceFeatureTable(new System.Uri(layerUrl)); // Create a feature layer from the service feature table. FeatureLayer districtFeatureLabel = new FeatureLayer(featureTable); // Add the feature layer to the operations layers collection of the map. sampleMap.OperationalLayers.Add(districtFeatureLabel); // Load the feature layer - this way we can obtain it's extent. await districtFeatureLabel.LoadAsync(); // Zoom the map view to the extent of the feature layer. await MyMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000); // Help regarding the Json syntax for defining the LabelDefinition.FromJson syntax can be found here: // https://developers.arcgis.com/web-map-specification/objects/labelingInfo/ // This particular JSON string will have the following characteristics: string redLabelJson = @"{ ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""}, ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"", ""where"":""PARTY = 'Republican'"", ""symbol"": { ""angle"":0, ""backgroundColor"":[0,0,0,0], ""borderLineColor"":[0,0,0,0], ""borderLineSize"":0, ""color"":[255,0,0,255], ""font"": { ""decoration"":""none"", ""size"":10, ""style"":""normal"", ""weight"":""normal"" }, ""haloColor"":[255,255,255,255], ""haloSize"":2, ""horizontalAlignment"":""center"", ""kerning"":false, ""type"":""esriTS"", ""verticalAlignment"":""middle"", ""xoffset"":0, ""yoffset"":0 } }"; string blueLabelJson = @"{ ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""}, ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"", ""where"":""PARTY = 'Democrat'"", ""symbol"": { ""angle"":0, ""backgroundColor"":[0,0,0,0], ""borderLineColor"":[0,0,0,0], ""borderLineSize"":0, ""color"":[0,0,255,255], ""font"": { ""decoration"":""none"", ""size"":10, ""style"":""normal"", ""weight"":""normal"" }, ""haloColor"":[255,255,255,255], ""haloSize"":2, ""horizontalAlignment"":""center"", ""kerning"":false, ""type"":""esriTS"", ""verticalAlignment"":""middle"", ""xoffset"":0, ""yoffset"":0 } }"; // Create a label definition from the JSON string. LabelDefinition redLabelDefinition = LabelDefinition.FromJson(redLabelJson); LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(blueLabelJson); // Add the label definition to the feature layer's label definition collection. districtFeatureLabel.LabelDefinitions.Add(redLabelDefinition); districtFeatureLabel.LabelDefinitions.Add(blueLabelDefinition); // Enable the visibility of labels to be seen. districtFeatureLabel.LabelsEnabled = true; }
private async void Chlorophyll_Clicked(object sender, EventArgs e) { // Set Button Colors WaveButton.BackgroundColor = Color.White; WaveButton.BorderColor = Color.FromHex("#5d7772"); WaveButton.TextColor = Color.FromHex("#5d7772"); ReefButton.BackgroundColor = Color.White; ReefButton.BorderColor = Color.FromHex("#5d7772"); ReefButton.TextColor = Color.FromHex("#5d7772"); WindButton.BackgroundColor = Color.White; WindButton.BorderColor = Color.FromHex("#5d7772"); WindButton.TextColor = Color.FromHex("#5d7772"); WaterButton.BackgroundColor = Color.White; WaterButton.BorderColor = Color.FromHex("#5d7772"); WaterButton.TextColor = Color.FromHex("#5d7772"); ChlorophyllButton.BackgroundColor = Color.FromHex("#5d7772"); ChlorophyllButton.BorderColor = Color.FromHex("#5d7772"); ChlorophyllButton.TextColor = Color.White; // set wms layers WmsLayer chlorophyll = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/nesdisVHNSQchlaDaily/request?service=WMS&request=GetCapabilities&version=1.3.0"), c1); WmsLayer chlorophylla = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/erdVH2018chla1day/request?service=WMS&request=GetCapabilities&version=1.3.0"), c2); WmsLayer chlorophyllb = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/erdVH2018chla1day/request?service=WMS&request=GetCapabilities&version=1.3.0"), c3); WmsLayer chlorophyllc = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/erdVH2018chla1day/request?service=WMS&request=GetCapabilities&version=1.3.0"), c4); WmsLayer chlorophylld = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/erdVH2018chla1day/request?service=WMS&request=GetCapabilities&version=1.3.0"), c5); WmsLayer chlorophylle = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/erdVH2018chla1day/request?service=WMS&request=GetCapabilities&version=1.3.0"), c6); WmsLayer chlorophyllf = new WmsLayer(new Uri("https://coastwatch.pfeg.noaa.gov/erddap/wms/erdVH2018chla1day/request?service=WMS&request=GetCapabilities&version=1.3.0"), c7); //create new map and basemap because the wms has a different coordinate projection system var myBasemap = new Basemap(); myBasemap.BaseLayers.Add(chlorophylle); myBasemap.BaseLayers.Add(chlorophylla); myBasemap.BaseLayers.Add(chlorophyllb); myBasemap.BaseLayers.Add(chlorophyllc); myBasemap.BaseLayers.Add(chlorophylld); myBasemap.BaseLayers.Add(chlorophyllf); myBasemap.BaseLayers.Add(chlorophyll); Esri.ArcGISRuntime.Mapping.Map myMapTwo = new Esri.ArcGISRuntime.Mapping.Map(myBasemap); // Get MapView from the view and assign map from view-model _mapView = MyMapView; _mapView.Map = myMapTwo; // start map zoomed in on the gulf string startingLatLon = "25.3043 -90.0659"; MapPoint startingPoint = CoordinateFormatter.FromLatitudeLongitude(startingLatLon, SpatialReferences.Wgs84); Viewpoint startingViewpoint = new Viewpoint(startingPoint, 1); // Set Viewpoint so that it is centered on the coordinates defined above await MyMapView.SetViewpointCenterAsync(startingPoint); //Set Legend LegendLabel.Text = " Chlorophyll Concentration"; LegendMetricLabel.Text = " mg m-3"; Box1.Color = Color.MediumPurple; Box2.Color = Color.Blue; Box3.Color = Color.LimeGreen; Box4.Color = Color.Orange; Box5.Color = Color.Red; MetricLabel1.Text = "0.1"; MetricLabel2.Text = "0.2"; MetricLabel3.Text = "1.0"; MetricLabel4.Text = "7.0"; MetricLabel5.Text = "20.0"; }
private void Initialize() { // Configure the basemap MyMapView.Map = new Map(Basemap.CreateTopographic()); // Create the graphics overlay _graphicsOverlay = new GraphicsOverlay(); // Add the overlay to the MapView MyMapView.GraphicsOverlays.Add(_graphicsOverlay); // Update the selection color MyMapView.SelectionProperties.Color = Color.Yellow; // Create the point collection that defines the polygon PointCollection polygonPoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-5991501.677830, 5599295.131468), new MapPoint(-6928550.398185, 2087936.739807), new MapPoint(-3149463.800709, 1840803.011362), new MapPoint(-1563689.043184, 3714900.452072), new MapPoint(-3180355.516764, 5619889.608838) }; // Create the polygon Polygon polygonGeometry = new Polygon(polygonPoints); // Define the symbology of the polygon SimpleLineSymbol polygonOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Green, 2); SimpleFillSymbol polygonFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Colors.Green, polygonOutlineSymbol); // Create the polygon graphic and add it to the graphics overlay _polygonGraphic = new Graphic(polygonGeometry, polygonFillSymbol); _graphicsOverlay.Graphics.Add(_polygonGraphic); // Create the point collection that defines the polyline PointCollection polylinePoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-4354240.726880, -609939.795721), new MapPoint(-3427489.245210, 2139422.933233), new MapPoint(-2109442.693501, 4301843.057130), new MapPoint(-1810822.771630, 7205664.366363) }; // Create the polyline Polyline polylineGeometry = new Polyline(polylinePoints); // Create the polyline graphic and add it to the graphics overlay _polylineGraphic = new Graphic(polylineGeometry, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Colors.Red, 4)); _graphicsOverlay.Graphics.Add(_polylineGraphic); // Create the point geometry that defines the point graphic MapPoint pointGeometry = new MapPoint(-4487263.495911, 3699176.480377, SpatialReferences.WebMercator); // Define the symbology for the point SimpleMarkerSymbol locationMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Blue, 10); // Create the point graphic and add it to the graphics overlay _pointGraphic = new Graphic(pointGeometry, locationMarker); _graphicsOverlay.Graphics.Add(_pointGraphic); // Listen for taps; the spatial relationships will be updated in the handler MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Set the viewpoint to center on the point MyMapView.SetViewpointCenterAsync(pointGeometry, 200000000); }
public ItemDetailPage(Item poiItem) { InitializeComponent(); // Create a view model with the current item (place category) this._viewModel = new ItemDetailViewModel(poiItem); BindingContext = _viewModel; // Create a symbol for the places (red circle), use it to create a renderer SimpleMarkerSymbol sym = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10); SimpleRenderer rndrr = new SimpleRenderer(sym); // Create a graphics overlay to show the places, add it to the map view _placesGraphicsOverlay = new GraphicsOverlay { Renderer = rndrr }; MyMapView.GraphicsOverlays.Add(_placesGraphicsOverlay); // Add the route graphics overlay _routeGraphicsOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(_routeGraphicsOverlay); // Zoom to the device location (Xamarin.Essentials) MyMapView.SpatialReferenceChanged += async(a, b) => { GeolocationRequest locationRequest = new GeolocationRequest(GeolocationAccuracy.Default); Location myLocation = await Geolocation.GetLocationAsync(locationRequest); MapPoint deviceLocation = new MapPoint(myLocation.Longitude, myLocation.Latitude, SpatialReferences.Wgs84); await MyMapView.SetViewpointCenterAsync(deviceLocation, 24000); }; // Use MapView.LocationDisplay to listen for location updates and for automatic display // When the location updates, store the last known location //MyMapView.LocationDisplay.IsEnabled = true; //MyMapView.LocationDisplay.LocationChanged += async(s, locArgs) => //{ // _deviceLocation = locArgs.Position; // await ShowPlaces(); //}; #region // Why is LocationDisplay null? // Search GeoNet: https://community.esri.com/search.jspa?place=%2Fplaces%2F191827&q=locationdisplay // -Answer from Zack (https://community.esri.com/message/875283-1006-locationdisplay-always-null) MyMapView.PropertyChanged += (o, e) => { if (e.PropertyName == nameof(MyMapView.LocationDisplay) && MyMapView.LocationDisplay != null) { // Enable your location display. MyMapView.LocationDisplay.IsEnabled = true; MyMapView.LocationDisplay.LocationChanged += async(s, locArgs) => { _deviceLocation = locArgs.Position; await ShowPlaces(); }; } }; #endregion // TODO: Uncomment to test compass control by setting map rotation //await MyMapView.SetViewpointRotationAsync(90); }