diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml index 9262ab5..b875cc1 100644 --- a/GisDevelop_Exp/MainWindow.xaml +++ b/GisDevelop_Exp/MainWindow.xaml @@ -15,8 +15,12 @@ + + + + + - diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs index 0232a58..e82d756 100644 --- a/GisDevelop_Exp/MainWindow.xaml.cs +++ b/GisDevelop_Exp/MainWindow.xaml.cs @@ -16,7 +16,9 @@ using System.Windows.Navigation; using System.Windows.Shapes; using Esri.ArcGISRuntime.Geometry; using Esri.ArcGISRuntime.Symbology; +using Esri.ArcGISRuntime.UI; using Color = System.Drawing.Color; +using Polygon = Esri.ArcGISRuntime.Geometry.Polygon; namespace GisDevelop_Exp { @@ -26,6 +28,10 @@ namespace GisDevelop_Exp public partial class MainWindow : Window { private FeatureLayer _featureLayer; + + private string _statesUrl = + "https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/USA_Daytime_Population_2016/FeatureServer/0"; + private ServiceFeatureTable _featureTable; public MainWindow() { InitializeComponent(); @@ -106,5 +112,87 @@ namespace GisDevelop_Exp graphicOverlay.Graphics.Add(envGraphic); EagleMapView.GraphicsOverlays.Add(graphicOverlay); } + + private double GetDistance(MapPoint p1, MapPoint p2) + { + double dx = p2.X - p1.X; + double dy = p2.Y - p1.Y; + return Math.Sqrt(dx * dx + dy * dy); + } + + private double GetAngle(MapPoint p1, MapPoint p2) + { + double dx = p2.X - p1.X; + double dy = p2.Y - p1.Y; + return Math.Atan2(dy, dx) * 180 / Math.PI; + } + + private void Menu_Zoom_in_OnClick(object sender, RoutedEventArgs e) + { + try + { + Viewpoint initViewpoint = MainMapView.GetCurrentViewpoint(ViewpointType.CenterAndScale); + MainMapView.SetViewpointScaleAsync(initViewpoint.TargetScale / 2.0); + } + catch (Exception exception) + { + Console.WriteLine(exception); + throw; + } + + } + + private void Menu_Zoom_out_OnClick(object sender, RoutedEventArgs e) + { + try + { + Viewpoint initViewpoint = MainMapView.GetCurrentViewpoint(ViewpointType.CenterAndScale); + MainMapView.SetViewpointScaleAsync(initViewpoint.TargetScale * 2.0); + } + catch (Exception exception) + { + Console.WriteLine(exception); + throw; + } + } + + private void Menu_OpenOnlineMap_OnClick(object sender, RoutedEventArgs e) + { + OpenOnlineData(); + } + + private async void OpenOnlineData() + { + Map pMap = new Map(); + pMap.Basemap=new Basemap(BasemapStyle.ArcGISTopographicBase); + _featureTable = new ServiceFeatureTable(new Uri(_statesUrl)); + _featureLayer = new FeatureLayer(_featureTable); + _featureLayer.MaxScale = 1.0; + await _featureLayer.LoadAsync(); + Viewpoint pVP = new Viewpoint(_featureLayer.FullExtent); + pMap.InitialViewpoint = pVP; + SimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Blue, 5.0); + SimpleLineSymbol pLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 5.0); + SimpleFillSymbol pFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Pink, pLineSymbol); + SimpleRenderer pRenderer = new SimpleRenderer(); + if (_featureLayer.FeatureTable.GeometryType == GeometryType.Polygon) + { + pRenderer.Symbol = pFillSymbol; + }else if (_featureLayer.FeatureTable.GeometryType == GeometryType.Point) + { + pRenderer.Symbol = pMarkerSymbol; + }else if (_featureLayer.FeatureTable.GeometryType == GeometryType.Polyline) + { + pRenderer.Symbol = pLineSymbol; + } + else + { + pRenderer.Symbol = pFillSymbol; + } + _featureLayer.Renderer = pRenderer; + pMap.OperationalLayers.Add(_featureLayer); + MainMapView.Map = pMap; + MainMapView.SelectionProperties.Color = Color.Cyan; + } } } diff --git a/GisDevelop_Exp/MapViewModel.cs b/GisDevelop_Exp/MapViewModel.cs index 1767665..73ef537 100644 --- a/GisDevelop_Exp/MapViewModel.cs +++ b/GisDevelop_Exp/MapViewModel.cs @@ -26,7 +26,6 @@ namespace GisDevelop_Exp _map = new Map(SpatialReferences.WebMercator) { InitialViewpoint = new Viewpoint(new Envelope(-180, -85, 180, 85, SpatialReferences.Wgs84)), -#warning To use ArcGIS location services (including basemaps) specify your API Key access token or require the user to sign in using a valid ArcGIS account. Basemap = new Basemap(BasemapStyle.ArcGISTopographic) }; }