Exemple #1
0
        public void OnMapReady(MapboxMap mapbox)
        {
            this.mapbox = mapbox;
            mapbox.SetStyle("mapbox://styles/luisortizs/ckdeotksa59vs1imw35jiqemz");

            ISharedPreferences preff = PreferenceManager.GetDefaultSharedPreferences(this);
            var latitud  = preff.GetString("LATITUD", "");
            var lognitud = preff.GetString("LONGITUD", "");

            Console.WriteLine(latitud, lognitud);

            double ltd = double.Parse(latitud);
            double lng = double.Parse(lognitud);

            var position = new CameraPosition.Builder()
                           .Target(new LatLng(ltd, lng))
                           .Zoom(13)
                           .Build();

            mapbox.AnimateCamera(CameraUpdateFactory.NewCameraPosition(position));
            ISharedPreferencesEditor edita = preff.Edit();

            edita.Clear();
            edita.Apply();
        }
 public void OnMapReady(MapboxMap map)
 {
     this.mapboxMap = map;
     map.SetStyle(Style.MAPBOX_STREETS, this);
     map.UiSettings.ZoomGesturesEnabled   = true;
     map.UiSettings.ScrollGesturesEnabled = true;
     map.UiSettings.SetAllGesturesEnabled(true);
 }
Exemple #3
0
 public void OnMapReady(MapboxMap p0)
 {
     p0.SetStyle(Style.MapboxStreets, new MyOnStyleLoaded(() =>
     {
         p0.AddOnMapLongClickListener(this);
         map = new NavigationMapboxMap(mapView, p0);
         map.SetOnRouteSelectionChangeListener(this);
         map.UpdateLocationLayerRenderMode(RenderMode.Compass);
         InitializeLocationEngine();
     }));
 }
Exemple #4
0
        public void OnMapReady(MapboxMap map)
        {
            mapboxMap = map;

            //var position = new CameraPosition.Builder()
            //			   .Target(new LatLng(41.885, -87.679)) // Sets the new camera position
            //			   .Zoom(11) // Sets the zoom
            //			   .Build(); // Creates a CameraPosition from the builder
            //         map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(position));

            map.SetStyle(Style.MAPBOX_STREETS, this);
        }
 public void OnMapReady(MapboxMap p0)
 {
     mapboxMap = p0;
     mapboxMap.AddOnMapLongClickListener(this);
     mapboxMap.SetStyle(Style.MapboxStreets, new MapboxMapSetStyleListener((style) =>
     {
         InitializeLocationEngine();
         InitializeLocationComponent(style);
         InitMapRoute();
         FetchRoute();
     }));
 }
Exemple #6
0
        public void OnMapReady(MapboxMap p0)
        {
            var mapboxMap = p0;

            this.mapboxMap = mapboxMap;
            mapboxMap.SetStyle(styleCycle.GetStyle(), new MapboxMapSetStyleListener((style) =>
            {
                InitializeLocationComponent(mapboxMap);
                navigationMapRoute = new NavigationMapRoute(null, mapView, mapboxMap);
                mapboxMap.AddOnMapLongClickListener(this);
                Snackbar.Make(mapView, "Long press to select route", Snackbar.LengthShort).Show();
            }));
        }
Exemple #7
0
        public void OnMapReady(MapboxMap mapbox)
        {
            this.mapbox = mapbox;
            mapbox.SetStyle("mapbox://styles/luisortizs/ckdeotksa59vs1imw35jiqemz");
            double ltd = 14.910448;
            double lng = -92.264833;

            var position = new CameraPosition.Builder()
                           .Target(new LatLng(ltd, lng))
                           .Zoom(13)
                           .Build();

            mapbox.AnimateCamera(CameraUpdateFactory.NewCameraPosition(position));
        }
Exemple #8
0
        public void OnMapReady(MapboxMap p0)
        {
            this.mapboxMap = p0;
            this.mapboxMap.AddOnMapClickListener(this);
            mapboxMap.SetStyle(Style.Dark, new MapboxMapSetStyleListener((style) =>
            {
                LocationComponent locationComponent = mapboxMap.LocationComponent;
                locationComponent.ActivateLocationComponent(this, style);
                locationComponent.LocationComponentEnabled = true;
                locationComponent.RenderMode = RenderMode.Gps;

                mockLocationEngine = new ReplayRouteLocationEngine();
                GetRoute(origin, destination);
            }));
        }
        public void OnMapReady(MapboxMap p0)
        {
            this.mapboxMap = p0;
            this.mapboxMap.AddOnMapClickListener(this);

            mapboxMap.SetStyle(Style.MapboxStreets, new MapboxMapSetStyleListener((style) =>
            {
                LocationComponent locationComponent = mapboxMap.LocationComponent;
                locationComponent.ActivateLocationComponent(this, style);
                locationComponent.RenderMode = RenderMode.Gps;
                locationComponent.LocationComponentEnabled = false;
                navigationMapRoute = new NavigationMapRoute(navigation, mapView, mapboxMap);
                Snackbar.Make(FindViewById <ConstraintLayout>(Resource.Id.container), "Tap map to place waypoint",
                              BaseTransientBottomBar.LengthLong).Show();
                locationEngine = new ReplayRouteLocationEngine();
                NewOrigin();
            }));
        }
Exemple #10
0
        public void OnMapReady(MapboxMap p0)
        {
            mapbox = p0;
            //System.Console.Write(p0);
            //mapbox.SetMinZoomPreference(11);

            //mapbox.SetStyle(Style.MAPBOX_STREETS ,this);



            mapbox.SetStyle(new Style.Builder().FromUri("mapbox://styles/abhishekswaraj23/ckcahuo1c44tz1ipjl72myvgz"), this);// mapbox://styles/abhishekswaraj23/ckca5b9ol1xyl1inypmizjc8g"),this);//"mapbox://styles/abhishekswaraj23/ckca5b9ol1xyl1inypmizjc8g"));

            //MarkerOptions marker = new MarkerOptions();
            //marker.SetPosition(new LatLng(21.0276, 105.8355));
            //marker.SetTitle("Xin Chao");
            //marker.SetSnippet("Well come to ViewNam");

            //mapbox.AddMarker(marker);

            mapbox.MarkerClick     += Mapbox_MarkerClick;
            mapbox.CameraMove      += Mapbox_CameraMove;
            mapbox.InfoWindowClick += Mapbox_InfoWindowClick;
        }
        public async void OnMapReady(MapboxMap mapBoxMap)
        {
            Toast.MakeText(_context, "Mapready invoked", ToastLength.Short).Show();
            _mapBoxMap = mapBoxMap;
            _mapBoxMap.SetStyle(Style.MapboxStreets);
            if (Connectivity.NetworkAccess != NetworkAccess.Internet)
            {
                //Getting the last downloaded definition to move the camera so that we see something when the map is loaded.
                var definition = await GetDefinition();

                _mapBoxMap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(new CameraPosition.Builder()
                                                                               .Target(definition.Bounds.Center)
                                                                               .Zoom(definition.MaxZoom).Build()));
            }
            else
            {
                var position = new CameraPosition.Builder()
                               .Target(new LatLng(13.0664, 80.2844))
                               .Zoom(15)
                               .Build();
                _mapBoxMap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(position));

                Toast.MakeText(_context,
                               $"Camera location pointed to Anna square, Chennai Lat : 13.0664 / Long: 80.2844",
                               ToastLength.Short)
                .Show();

                var markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(13.0664, 80.2844));
                markerOptions.SetTitle("Anna square");
                markerOptions.SetIcon(IconFactory.GetInstance(_context)
                                      .FromResource(Resource.Drawable.mapbox_marker_icon_default));

                _mapBoxMap.AddMarker(markerOptions);
            }
        }
Exemple #12
0
        public void OnMapReady(MapboxMap mapBox)
        {
            nMap = mapBox;
            nMap.SetStyle(Map.mapStyle, this);
            //nMap.SetStyle("mapbox://styles/mapbox/light-v9");
            nMap.UiSettings.CompassEnabled = false;
            nMap.AddOnMapClickListener(this);
            nMap.CameraIdle        += NMap_CameraIdle;
            nMap.CameraMoveStarted += NMap_CameraMoveStarted;
            nMap.CameraMove        += NMap_CameraMove;

            // If cross map has not been assigned a value yet the retry initializations in the next x millisecond
            if (xMap == null)
            {
                return;
            }

            if (xMap.initialCameraUpdate != null)
            {
                updateMapPerspective(xMap.initialCameraUpdate);
            }

            System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff tt") + "[MapboxRenderer]: Ready Ready Ready Ready Ready");
        }
 private void MainActivity_Click(object sender, System.EventArgs e)
 {
     mapboxMap.SetStyle(Style.DARK);
 }
 public void OnMapReady(MapboxMap mapboxMap)
 {
     // Com.Mapbox.Mapboxsdk.Constants.Style.Light = mapbox://styles/mapbox/light-v9
     mapboxMap.SetStyle("mapbox://styles/mapbox/light-v9", new OnStyleLoadedListener(mapboxMap));
 }
        //Implements the IOnMapReadyCallback interface
        public void OnMapReady(MapboxMap map)
        {
            mapboxMap = map;

            // This will refer to OnStyleLoaded
            map.SetStyle(Style.MapboxStreets, this);
            var title1 = "Chicago";
            var lat1   = 41.897627;
            var lng1   = -87.643526;
            var title2 = "St.Louis";
            var lat2   = 38.742291;
            var lng2   = -90.064928;

            pickupPoint   = new LatLng(lat1, lng1);
            delivertPoint = new LatLng(lat2, lng2);

            bool crossesMeridianOrDateline;

            if ((lng1 > 0.0 && lng2 < 0.0) || (lng1 < 0.0 && lng2 > 0.0))
            {
                crossesMeridianOrDateline = true;
            }
            else
            {
                crossesMeridianOrDateline = false;
            }

            var xDiffPrimeMeridianZero = FindXDiffPrimeMeridianZero(lng1, lng2);
            var xDiffDatelineZero      = FindXDiffDatelineZero(lng1, lng2);

            List <double> xList;
            List <double> lngList;

            if ((Math.Abs(xDiffDatelineZero) > Math.Abs(xDiffPrimeMeridianZero)) && crossesMeridianOrDateline == true)
            {
                var latCenter = (lat1 + lat2) / 2.0;

                // Find center coordinate here
                var    x1      = FindXPrimeMeridianZero(lng1);
                var    xCenter = x1 + (xDiffPrimeMeridianZero / 2.0);
                double lngCenter;

                if (x1 > 180.0)
                {
                    lngCenter = xCenter - 360.0;
                }
                else
                {
                    lngCenter = xCenter;
                }

                var cameraCenter = new CameraPosition.Builder().Target(new LatLng(latCenter, lngCenter)).Zoom(1.5).Build();

                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraCenter));

                xList   = CreateXList(xDiffPrimeMeridianZero, x1);
                lngList = ConvertToLngsPrimeMeridianZero(xList);
            }
            else
            {
                // find max/min lat/lng here
                // use those to determine the initialBounds

                var latDict = FindLowHigh(lat1, lat2);
                var latHigh = latDict["high"];
                var latLow  = latDict["low"];
                var lngDict = FindLowHigh(lng1, lng2);
                var lngHigh = lngDict["high"];
                var lngLow  = lngDict["low"];

                var latBuffer = (latHigh - latLow) / 4.0;
                var lngBuffer = (lngHigh - lngLow) / 10.0;

                var swLat = latLow - latBuffer;
                var swLng = lngLow - lngBuffer;
                var neLat = latHigh + latBuffer;
                var neLng = lngHigh + lngBuffer;

                var swPoint = new LatLng(swLat, swLng);
                var nePoint = new LatLng(neLat, neLng);

                var latLngBounds = new LatLngBounds.Builder()
                                   .Include(nePoint) // Northeast
                                   .Include(swPoint) // Southwest
                                   .Build();

                mapboxMap.EaseCamera(CameraUpdateFactory.NewLatLngBounds(latLngBounds, 0));

                xList   = CreateXList(xDiffDatelineZero, FindXDatelineZero(lng1));
                lngList = ConvertToLngsDatelineZero(xList);
            }

            var yList = CreateYList(lat1, lat2);

            var latList = ConvertToLats(yList);
            var coords  = ConvertToCoords(latList, lngList);

            CreateDashedLine(coords);

            var marker1 = new MarkerOptions();
            var marker2 = new MarkerOptions();

            marker1.SetPosition(pickupPoint);
            marker1.SetTitle(title1);
            marker2.SetPosition(delivertPoint);
            marker2.SetTitle(title2);
            map.AddMarker(marker1);
            map.AddMarker(marker2);
        }