private async void BuildingRouteAsync()
        {
            var             id      = Intent.GetStringExtra(IDPED);
            string          sql     = string.Format("Select * From TapFood.Pedido Where(IdPedido='{0}') Limit 1", id);
            MySqlCommand    command = new MySqlCommand(sql, conn);
            MySqlDataReader reader;

            reader = command.ExecuteReader();
            reader.Read();
            double latusr = (double)reader["LatitudUsuario"];
            double lngusr = (double)reader["LongitudUsuario"];
            double latrep = (double)reader["LatitudRepartidor"];
            double lngrep = (double)reader["LongitudRepartidor"];

            MapboxNavigation navigation = new MapboxNavigation(this, MAPBOX_KEY);

            Point origin      = Point.FromLngLat(lngusr, latusr);
            Point destination = Point.FromLngLat(lngrep, latrep);

            var response = await NavigationRoute
                           .GetBuilder()
                           .AccessToken(Mapbox.AccessToken)
                           .Origin(origin)
                           .Destination(destination)
                           .Build()
                           .GetRouteAsync();

            System.Diagnostics.Debug.WriteLine(response);
        }
 public static Position ToForms(this Point position)
 {
     return(new Position
     {
         Lat = position.Latitude(),
         Long = position.Longitude()
     });
 }
Exemple #3
0
        public void UserOffRoute(Location location)
        {
            Com.Mapbox.Geojson.Point newOrigin = Com.Mapbox.Geojson.Point.FromLngLat(location.Longitude, location.Latitude);
            GetRoute(newOrigin, destination, location.Bearing);
            Snackbar.Make(contentLayout, "User Off Route", Snackbar.LengthShort).Show();
            var markerOptions = new MarkerOptions().Position(new LatLng(location.Latitude, location.Longitude));

            mapboxMap.AddMarker(Android.Runtime.Extensions.JavaCast <MarkerOptions>(markerOptions));
        }
Exemple #4
0
 void GetRoute(Com.Mapbox.Geojson.Point origin, Com.Mapbox.Geojson.Point destination, double?bearing)
 {
     NavigationRoute
     .GetBuilder()
     .Origin(origin, bearing.HasValue ? new Java.Lang.Double(bearing.Value) : null, new Java.Lang.Double(90))
     .Destination(destination)
     .AccessToken(Mapbox.AccessToken)
     .Build()
     .GetRoute(this);
 }
Exemple #5
0
        public void OnMapClick(LatLng point)
        {
            if (!running || mapboxMap == null)
            {
                return;
            }

            mapboxMap.AddMarker(Android.Runtime.Extensions.JavaCast <MarkerOptions>(new MarkerOptions().Position(point)));
            mapboxMap.SetOnMapClickListener(null);

            Com.Mapbox.Geojson.Point newDestination = Com.Mapbox.Geojson.Point.FromLngLat(point.Longitude, point.Latitude);
            mockLocationEngine.MoveToLocation(newDestination);
            destination = Com.Mapbox.Geojson.Point.FromLngLat(point.Longitude, point.Latitude);
            tracking    = false;
        }