예제 #1
0
        private async void CalculateRouteToDisplay()
        {
            // Clear map routes
            Map.Routes.Clear();

            // Get list of all longitude and latitude values from our Stops
            List <BasicGeoposition> allLongitudesAndLatitudes = new List <BasicGeoposition>();

            foreach (var stop in Stops)
            {
                allLongitudesAndLatitudes.Add(new BasicGeoposition()
                {
                    Latitude  = decimal.ToDouble(stop.Latitude),
                    Longitude = decimal.ToDouble(stop.Longitude)
                });
            }

            if (allLongitudesAndLatitudes.Count >= 2)
            {
                var route = await mapService.CalculateRoute(allLongitudesAndLatitudes);

                if (route != null)
                {
                    route.RouteColor   = Colors.Yellow;
                    route.OutlineColor = Colors.Black;
                    Map.Routes.Add(route);
                }

                SetBounds(route);
            }
        }
예제 #2
0
        /// <summary>
        /// This function takes in a list of geopositions, and tells the map
        /// service to create a route using this list. Existing routes on the
        /// map are cleared.
        /// </summary>
        /// <param name="stopLocations"></param>
        private async void ReDrawRoute(List <BasicGeoposition> stopLocations)
        {
            // Clear routes from Map
            Map.Routes.Clear();

            var route = await mapService.CalculateRoute(stopLocations);

            if (route != null)
            {
                route.RouteColor   = Colors.Yellow;
                route.OutlineColor = Colors.Black;
                Map.Routes.Add(route);
            }

            // Set the view of the map to encompass all of the route
            RetrieveBoundingBox(route.Route.BoundingBox);
        }