private async void setMapInitialExtent(Viewpoint viewpoint) { await MainMapView.SetViewpointAsync(viewpoint); // TODO: Set Center //await MainMapView.SetViewpointCenterAsync(viewpoint.GetCenter()); mapViewModel.InitialViewpoint = viewpoint; }
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; }