public MainWindow() { InitializeComponent(); MapPoint mapCenterPoint = new MapPoint(-118.805, 34.027, SpatialReferences.Wgs84); MainMapView.SetViewpoint(new Viewpoint(mapCenterPoint, 100000)); }
private async void setMapInitialExtent(Viewpoint viewpoint) { await MainMapView.SetViewpointAsync(viewpoint); // TODO: Set Center //await MainMapView.SetViewpointCenterAsync(viewpoint.GetCenter()); mapViewModel.InitialViewpoint = viewpoint; }
private async void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(ViewModel.SelectedPatternElement) && ViewModel.SelectedPatternElement != null) { PatternElement elem = ViewModel.SelectedPatternElement; var point = new MapPoint(elem.Longitude, elem.Latitude, MapHelper.BUS_ROUTES_SR); await MainMapView.SetViewpointCenterAsync(point); await MainMapView.SetViewpointScaleAsync(2000); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { ViewModel.SelectedRoute = e.Parameter as Route; ViewModel.PropertyChanged += ViewModel_PropertyChanged; MapHelper.LoadMap(MainMapView); await ViewModel.LoadPatternsAsync(); DrawingColor = ColorHelper.ParseCSSColorAsDrawingColor(ViewModel.SelectedRoute.Color); bool hasRoutePoints = ViewModel.PatternElements.Count != 0; if (hasRoutePoints) { var routePoints = ViewModel.PatternElements.Select(p => new MapPoint(p.Longitude, p.Latitude, MapHelper.BUS_ROUTES_SR)); var routePath = new PolylineBuilder(routePoints, MapHelper.BUS_ROUTES_SR).ToGeometry(); // Create a simple line symbol to display the polyline var routeLineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, DrawingColor, 4.0 ); MapGraphics.Graphics.Add(new Graphic(routePath, routeLineSymbol)); await MainMapView.SetViewpointGeometryAsync(routePath); foreach (PatternElement elem in ViewModel.Stops) { var point = new MapPoint(elem.Longitude, elem.Latitude, MapHelper.BUS_ROUTES_SR); var stop = MapHelper.CreateRouteStop(point, DrawingColor); MapGraphics.Graphics.Add(stop); } } MapHelper.SetViewpointToCurrentLocation(MainMapView, MapGraphics, Geolocator_PositionChanged, !hasRoutePoints); // Show time table await ViewModel.LoadTimeTableAsync(); TimeTablePresenter.Content = TimeTableUIFactory.CreateGridFromTimeTable(ViewModel.TimeTable); base.OnNavigatedTo(e); }
private void ButtonFullExtent_Click(object sender, RoutedEventArgs e) => MainMapView.SetViewpoint(mapViewModel.InitialViewpoint);
async void Button_Clicked(System.Object sender, System.EventArgs e) { // Assign the map to the MapView. MainMapView.Map = new Map(BasemapStyle.ArcGISNavigation); await MainMapView.Map.LoadAsync(); //MapPoint mapCenterPoint = new MapPoint(, SpatialReferences.WebMercator); await MainMapView.SetViewpointAsync(new Viewpoint(52.0135053, 4.3367553, 72223.819286)); // Create the route task, using the online routing service. RouteTask routeTask = await RouteTask.CreateAsync(_routingUri); // Get the default route parameters. RouteParameters routeParams = await routeTask.CreateDefaultParametersAsync(); // Explicitly set values for parameters. routeParams.ReturnDirections = true; routeParams.ReturnStops = true; routeParams.ReturnRoutes = true; routeParams.OutputSpatialReference = SpatialReferences.Wgs84; // Create stops for each location. Stop stop1 = new Stop(_conventionCenter) { Name = "Delft Netherlands" }; Stop stop2 = new Stop(_memorial) { Name = "Rotterdam Netherlands" }; //Stop stop3 = new Stop(_aerospaceMuseum) { Name = "Amsterdam Netherlands" }; // Assign the stops to the route parameters. List <Stop> stopPoints = new List <Stop> { stop1, stop2 }; routeParams.SetStops(stopPoints); // Get the route results. _routeResult = await routeTask.SolveRouteAsync(routeParams); _route = _routeResult.Routes[0]; // Add a graphics overlay for the route graphics. MainMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Add graphics for the stops. SimpleMarkerSymbol stopSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.OrangeRed, 20); MainMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_conventionCenter, stopSymbol)); MainMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_memorial, stopSymbol)); //MainMapView.GraphicsOverlays[0].Graphics.Add(new Graphic(_aerospaceMuseum, stopSymbol)); // Create a graphic (with a dashed line symbol) to represent the route. _routeAheadGraphic = new Graphic(_route.RouteGeometry) { Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.BlueViolet, 5) }; // Create a graphic (solid) to represent the route that's been traveled (initially empty). _routeTraveledGraphic = new Graphic { Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.LightBlue, 3) }; // Add the route graphics to the map view. MainMapView.GraphicsOverlays[0].Graphics.Add(_routeAheadGraphic); MainMapView.GraphicsOverlays[0].Graphics.Add(_routeTraveledGraphic); // Set the map viewpoint to show the entire route. await MainMapView.SetViewpointGeometryAsync(_route.RouteGeometry, 100); // Enable the navigation button. StartNavigationButton.IsEnabled = true; }