コード例 #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();
        }
コード例 #2
0
        public void OnMapReady(MapboxMap map)
        {
            var uiSettings = map.UiSettings;

            uiSettings.SetAllGesturesEnabled(true);

            var marker = new MarkerOptions();

            marker.SetTitle("Los Angeles");
            marker.SetSnippet("City Hall");
            marker.SetPosition(LOS_ANGELES);

            map.AddMarker(marker);

            marker.SetTitle("New York");
            marker.SetSnippet("City Hall");
            marker.SetPosition(NEW_YORK);

            map.AddMarker(marker);

            var bounds = new LatLngBounds.Builder()
                         .Include(NEW_YORK)
                         .Include(LOS_ANGELES)
                         .Build();

            map.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 8));
        }
コード例 #3
0
ファイル: Additions.cs プロジェクト: cyecp/XamarinComponents
 public void OnMapReady(MapboxMap map)
 {
     if (OnMapReadyHandler != null)
     {
         OnMapReadyHandler(map);
     }
 }
コード例 #4
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            mapView             = FindViewById <MapView> (Resource.Id.mapview);
            mapView.AccessToken = GetString(Resource.String.mapboxAccessToken);
            mapView.StyleUrl    = Mapbox.Constants.Style.Emerald;
            mapView.OnCreate(bundle);

            // Get the map instance
            map = await mapView.GetMapAsync();

            map.MarkerClick += async(sender, e) => {
                e.Handled = false;
                Toast.MakeText(this, "Marker Click: " + e.Marker.Title, ToastLength.Short).Show();
            };
            map.InfoWindowClick += async(sender, e) => {
                Toast.MakeText(this, "Info Window Click: " + e.Marker.Title, ToastLength.Short).Show();
            };
            map.AddMarker(new MarkerOptions()
                          .SetTitle("Test Marker")
                          .SetPosition(new LatLng(41.885, -87.679)));

            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), 3000);
        }
コード例 #5
0
 public void OnMapReady(MapboxMap mapboxMap)
 {
     mapboxMap.AddMarker(new Com.Mapbox.Mapboxsdk.Annotations.MarkerOptions().SetPosition(new LatLng(40.416717, -3.703771)).SetTitle("spain"));
     mapboxMap.AddMarker(new Com.Mapbox.Mapboxsdk.Annotations.MarkerOptions().SetPosition(new LatLng(26.794531, 29.781524)).SetTitle("egypt"));
     mapboxMap.AddMarker(new Com.Mapbox.Mapboxsdk.Annotations.MarkerOptions().SetPosition(new LatLng(50.981488, 10.384677)).SetTitle("germany"));
     mapboxMap.InfoWindowAdapter = new InfoWindowAdapter(_context);
 }
コード例 #6
0
        public void OnMapReady(MapboxMap p0)
        {
            map = p0;

            map.MyLocationEnabled = true;
            map.UiSettings.RotateGesturesEnabled = Element.RotateEnabled;
            map.UiSettings.TiltGesturesEnabled   = Element.PitchEnabled;

            if (Element.Center != null)
            {
                map.CameraPosition = new CameraPosition.Builder()
                                     .Target(Element.Center.ToLatLng())
                                     .Zoom(Element.ZoomLevel)
                                     .Build();
            }
            else
            {
                map.CameraPosition = new CameraPosition.Builder()
                                     .Target(map.CameraPosition.Target)
                                     .Zoom(Element.ZoomLevel)
                                     .Build();
            }

            AddMapEvents();

            SetupFunctions();
            UpdateMapStyle();
        }
 public void OnMapReady(MapboxMap mapboxMap)
 {
     this.mapboxMap = mapboxMap;
     this.mapboxMap.SetOnMapLongClickListener(this);
     InitLocationEngine();
     InitLocationLayer();
     InitMapRoute();
 }
コード例 #8
0
 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);
 }
コード例 #9
0
        protected async Task <bool> loadMap(Bundle bundle)
        {
            //Attempts to create the mapview with the specified style using our Mapbox credentials, logs the exception if it fails
            try
            {
                Mapbox.MapboxAccountManager.Start(this, GetString(Resource.String.mapboxAccessToken));
                mapView.StyleUrl = "mapbox://styles/andrewharris/cj4x3b6hd2i412sqnrg5sipbt";
                mapView.OnCreate(bundle);
            }
            catch (Exception e)
            {
                Log.Debug("MapActivity.loadMap", e.StackTrace);
            }

            //Makes a default camera while waiting for the user's location to be determined
            var cameraPosition = new CameraPosition.Builder()
                                 .Target(new LatLng(40.7128, -74.0059)) // Sets the new camera position
                                 .Zoom(9)                               // Sets the zoom
                                 .Build();                              // Creates a CameraPosition from the builder

            //Attempts to initialize the map field, returns false (failure) if unable to
            try
            {
                map = await mapView.GetMapAsync();
            }
            catch (Exception e)
            {
                return(false);
            }
            //Sets up the map UI elements, disables tilt gestures, the Mapbox logo, and the compass
            map.UiSettings.TiltGesturesEnabled = false;
            map.UiSettings.LogoEnabled         = false;
            map.UiSettings.CompassEnabled      = false;

            //Tries to mark the user's location on the map and setup a user-centered camera, uses the default camera position otherwise
            try
            {
                Tools.markUserLocation(map);
            }
            catch (Exception e)
            {
                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition), 3000);
                Log.Error(TAG, e.StackTrace);
                return(false);
            }

            //Binds delegate to handle the recentering floating action button
            FindViewById <FloatingActionButton>(Resource.Id.recenterOnUserActionButton).Click += delegate
            {
                cameraPosition = new CameraPosition.Builder()
                                 .Target(new LatLng(map.MyLocation.Latitude, map.MyLocation.Longitude))
                                 .Zoom(13)
                                 .Tilt(0)
                                 .Build();
                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition), 3000);
            };
            return(true); //If it was successfully able to set up the user-centered map, return a success flag
        }
コード例 #10
0
        //Clears all routes on the map
        public static void clearRoutes(MapboxMap map)
        {
            var polylines = map.Polylines;

            foreach (var polyline in polylines)
            {
                map.RemovePolyline(polyline);
            }
        }
コード例 #11
0
        public void OnMapReady(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));
        }
コード例 #12
0
 public AutocompleteSuggestionUpdater(AutoCompleteTextView view, ArrayAdapterNoFilter adapter, MapboxMap map, MapBoxInterface mbi)
 {
     this.view    = view;
     this.adapter = adapter;
     this.map     = map;
     this.mbi     = mbi;
     updateAdapter("Central Park");
     adapter.Clear();
 }
コード例 #13
0
        protected override void OnStart()
        {
            int i = 0;

            base.OnStart();
            // this.AttachEvents();
            this.mapView.OnStart();
            if (this.firstLoad)
            {
                this.firstLoad = false;
                this.performOperatoinOnMap((map) =>
                {
                    this.Map = map;
                    this.Map.UiSettings.RotateGesturesEnabled = false;
                    this.Map.SetOnMapClickListener(this);
                    //this.Map.SetOnMarkerClickListener(this);
                    this.Map.SetOnScrollListener(this);
                    this.ZoomToDefaultView();
                    var position = new CameraPosition.Builder()
                                   .Target(new LatLng(28.60831, 77.36114))
                                   .Zoom(8)
                                   .Build();


                    foreach (var item in lstLatLng)
                    {
                        markerViewOptions = new MarkerViewOptions();
                        markerViewOptions.InvokeIcon(StoppedIcon);
                        markerViewOptions.InvokePosition(item);
                        markerViewOptions.InvokeRotation((float)item.Latitude);
                        markerViewOptions.InvokeSnippet("Well come to RSystem");
                        markerViewOptions.InvokeTitle("RSystem");
                        Map.AddMarker(markerViewOptions);
                        // lstMarker.Add(markerViewOptions);

                        polylineOptions.Add(item);
                        polylineOptions.InvokeWidth(5);
                        if (i % 2 == 0)
                        {
                            polylineOptions.InvokeColor(Color.Red);
                        }
                        else
                        {
                            polylineOptions.InvokeColor(Color.Green);
                        }
                        // lstPolyline.Add(polylineOptions);
                        //  Map.AddPolyline(polylineOptions);
                        i++;
                    }

                    // Map.AddPolylines(lstPolyline);

                    this.Map.MoveCamera(CameraUpdateFactory.NewCameraPosition(position));
                });
            }
        }
コード例 #14
0
ファイル: MapView.cs プロジェクト: klzig/MapX
        public void OnMapReady(MapboxMap map)
        {
            _mapboxMap = map;
            var position = new CameraPosition.Builder()
                           .Target(new LatLng(43.6332, -116.216)) // Sets the new camera position
                           .Zoom(11)                              // Sets the zoom
                           .Build();                              // Creates a CameraPosition from the builder

            _mapboxMap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(position));
        }
コード例 #15
0
        private void InitializeLocationComponent(MapboxMap mapboxMap)
        {
            LocationComponent locationComponent = mapboxMap.LocationComponent;

            locationComponent.ActivateLocationComponent(this, mapboxMap.Style);
            locationComponent.LocationComponentEnabled = true;
            locationComponent.RenderMode = RenderMode.Compass;
            locationComponent.CameraMode = CameraMode.Tracking;
            locationComponent.ZoomWhileTracking(10d);
        }
コード例 #16
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();
     }));
 }
コード例 #17
0
 internal void ToggleInfoWindow(MapboxMap mapboxMap, Marker marker)
 {
     if (marker.IsInfoWindowShown)
     {
         mapboxMap.DeselectMarker(marker);
     }
     else
     {
         mapboxMap.SelectMarker(marker);
     }
 }
コード例 #18
0
 public void OnMapReady(MapboxMap p0)
 {
     mapboxMap = p0;
     mapboxMap.AddOnMapLongClickListener(this);
     mapboxMap.SetStyle(Style.MapboxStreets, new MapboxMapSetStyleListener((style) =>
     {
         InitializeLocationEngine();
         InitializeLocationComponent(style);
         InitMapRoute();
         FetchRoute();
     }));
 }
        public void OnMapReady(MapboxMap mapboxMap)
        {
            this.mapboxMap     = mapboxMap;
            navigationMapRoute = new NavigationMapRoute(null, mapView, mapboxMap, "admin-3-4-boundaries-bg");
            Gson gson = new GsonBuilder().RegisterTypeAdapterFactory(DirectionsAdapterFactory.Create()).Create();
            var  json = loadJsonFromAsset(DIRECTIONS_RESPONSE);
            DirectionsResponse response = (DirectionsResponse)gson.FromJson(json, Class.FromType(typeof(DirectionsResponse)));

            navigationMapRoute.AddRoute(response.Routes()[0]);
            mapboxMap.SetOnMapLongClickListener(this);
            navigationMapRoute.SetOnRouteSelectionChangeListener(this);
        }
コード例 #20
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);
        }
コード例 #21
0
 private void InitializeNavigation(MapboxMap mapboxMap)
 {
     navigation = new Mapbox.Services.Android.Navigation.V5.Navigation.MapboxNavigation(this, Mapbox.Mapboxsdk.Mapbox.AccessToken);
     navigation.LocationEngine = locationEngine;
     sendAnomalyFab.Show();
     navigation.CameraEngine = new DynamicCamera(mapboxMap);
     navigation.AddProgressChangeListener(this);
     navigation.AddMilestoneEventListener(this);
     navigation.AddOffRouteListener(this);
     navigationMap.AddProgressChangeListener(navigation);
     AddNavigationForHistory(navigation);
 }
コード例 #22
0
        //Sets the camera so it can view the overall route
        public static void setRoutingCamera(double[] origin, double[] destination, MapboxMap map)
        {
            //Finds the center point between the origin and destination
            double[] center = new double[] { (origin[0] + destination[0]) / 2, (origin[1] + destination[1]) / 2 };
            //Sets a camera position at that location with an assumed zoom of 12 (usually okay, should be adjusted based on distance between locations eventually)
            var cameraPosition = new CameraPosition.Builder()
                                 .Target(new LatLng(center[0], center[1])) // Sets the new camera position
                                 .Zoom(12)                                 // Sets the zoom
                                 .Build();                                 // Creates a CameraPosition from the builder

            //Sets that camera for viewing the map
            map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition), 1000);
        }
コード例 #23
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();
            }));
        }
コード例 #24
0
ファイル: MapPage.cs プロジェクト: luisortizla/tfr
        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));
        }
コード例 #25
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);
            }));
        }
コード例 #26
0
        public void OnMapReady(MapboxMap mapboxMap)
        {
            this.mapboxMap = mapboxMap;
            mapboxMap.SetOnMapClickListener(this);

            locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
            locationLayerPlugin.SetLocationLayerEnabled(LocationLayerMode.Navigation);

            // Setup the mockLocationEngine
            mockLocationEngine = new MockLocationEngine(1000, 30, false);
            mockLocationEngine.AddLocationEngineListener(this);
            navigation.LocationEngine = (mockLocationEngine);

            // Acquire the navigation route
            GetRoute(origin, destination, null);
        }
コード例 #27
0
        public void OnMapReady(MapboxMap mapboxMap)
        {
            this.mapboxMap = mapboxMap;

            locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
            locationLayerPlugin.SetLocationLayerEnabled(LocationLayerMode.Navigation);

            navigationMapRoute = new NavigationMapRoute(navigation, mapView, mapboxMap);

            mapboxMap.SetOnMapClickListener(this);
            Snackbar.Make(mapView, "Tap map to place waypoint", BaseTransientBottomBar.LengthLong).Show();

            locationEngine = new MockLocationEngine(1000, 50, true);
            mapboxMap.SetLocationSource(locationEngine);

            NewOrigin();
        }
コード例 #28
0
        //Marks the user's location on the map
        public static void markUserLocation(MapboxMap map)
        {
            //Enables location tracking, sets the desired accuracy to 10m, sets the accuracy ring to have 75% opacity
            map.MyLocationEnabled   = true;
            map.MyLocation.Accuracy = 10;
            map.MyLocationViewSettings.AccuracyAlpha = 75;

            //Sets up a camera centered on the user
            var cameraPosition = new CameraPosition.Builder()
                                 .Target(new LatLng(map.MyLocation.Latitude, map.MyLocation.Longitude))
                                 .Zoom(13)
                                 .Tilt(0)
                                 .Build();

            //Sets that camera for viewing the map
            map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition), 1000);
        }
コード例 #29
0
        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();
            }));
        }
コード例 #30
0
        public void OnMapReady(MapboxMap p0)
        {
            var mapboxMap = p0;

            mapboxMap.SetStyle(new Style.Builder().FromUrl(GetString(Resource.String.navigation_guidance_day)), new MapboxMapSetStyleListener((Style) =>
            {
                mapState      = MapState.INFO;
                navigationMap = new NavigationMapboxMap(mapView, mapboxMap);

                // For Location updates
                InitializeLocationEngine();

                // For navigation logic / processing
                InitializeNavigation(mapboxMap);
                navigationMap.UpdateCameraTrackingMode(NavigationCamera.NavigationTrackingModeNone);
                navigationMap.UpdateLocationLayerRenderMode(RenderMode.Gps);

                // For voice instructions
                InitializeSpeechPlayer();
            }));
        }