Esempio n. 1
0
        public static async Task <string> GetPolyline(Coordinate origin, Coordinate destination, List <Coordinate> waypoints = null)
        {
            MapDirectionResponse MDR = await MapFunction.GetDirectionJsonAsync(origin, destination, waypoints);

            if (MDR.routes.Count == 0)
            {
                return(null);
            }
            tongquangduong += MDR.routes.FirstOrDefault().legs.FirstOrDefault().distance.value;

            List <Coordinate> PolylinePoints = new List <Coordinate>();

            foreach (Leg leg in MDR.routes[0].legs)
            {
                foreach (Step step in leg.steps)
                {
                    List <Coordinate> miniPolylinePoints = MapFunction.Decode(step.polyline.points).ToList();
                    miniPolylinePoints.Remove(miniPolylinePoints.Last());

                    PolylinePoints.AddRange(miniPolylinePoints);
                }
            }
            Coordinate lastPolylinePoint = MapFunction.Decode(MDR.routes[0].legs.Last().steps.Last().polyline.points).Last();

            PolylinePoints.Add(lastPolylinePoint);

            string Polyline = MapFunction.Encode(PolylinePoints);

            return(Polyline);
        }
Esempio n. 2
0
        public static async Task <double> GetDistanceAsync(Coordinate origin, Coordinate destination, List <Coordinate> waypoints = null)
        {
            MapDirectionResponse mapDirectionResponse = await GetDirectionJsonAsync(origin, destination, waypoints);

            double distance = 0;

            foreach (Leg leg in mapDirectionResponse.routes[0].legs)
            {
                distance += leg.distance.value;
            }
            return(distance);
        }
Esempio n. 3
0
        public static IEnumerable <Coordinate> GetOverviewPolylinePoints(MapDirectionResponse mapDirectionResponse)
        {
            string overview_polyline = mapDirectionResponse.routes[0].overview_polyline.points;

            return(Decode(overview_polyline));
        }