Ejemplo n.º 1
0
        partial void routeButton_TouchUpInside(UIButton sender)
        {
            if (MapRoute != null)
            {
                MapView.RemoveMapObject(MapRoute);
                MapRoute = null;
            }

            // START: Daimler Fleetboard
            NMAGeoCoordinates start = new NMAGeoCoordinates(48.7244153, 9.1161991);
            // END: Biergarten
            NMAGeoCoordinates end = new NMAGeoCoordinates(48.701356, 9.1393803);

            // Create an NSMutableArray to add two stops
            NSObject[] stops = new NSObject[] { start, end };

            NMARoutingMode routingMode = new NMARoutingMode(NMARoutingType.Fastest, NMATransportMode.Car, NMARoutingOption.Highway);

            // Initialize the NMACoreRouter
            if (Router == null)
            {
                Router = new NMACoreRouter();
            }
            // Trigger the route calculation
            Router.CalculateRouteWithStops(stops, routingMode, OnCalculateRouteCompletion);
        }
Ejemplo n.º 2
0
        private void OnCalculateRouteCompletion(NMARouteResult routeResult, NMARoutingError error)
        {
            if (routeResult != null && routeResult.Routes.Length >= 1)
            {
                // Let's add the 1st result onto the map
                NMARoute route = routeResult.Routes[0];
                MapRoute = new NMAMapRoute(route);
                MapView.AddMapObject(MapRoute);

                // In order to see the entire route, we orientate the map view
                // accordingly
                MapView.SetBoundingBox(route.BoundingBox, NMAMapAnimation.Linear);
            }
            else
            {
                Console.WriteLine("Error:route result returned is not valid");
                Console.WriteLine("Error:route calculation returned error code %d", (int)error);
            }
        }