Beispiel #1
0
        //--------------------------------------------------------------------
        // EXTERNAL METHODS
        //--------------------------------------------------------------------

        private void MoveToLocation(GeoLocation geoLocation, float zoom = -1)
        {
            if (geoLocation == null)
            {
                return;
            }

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(new LatLng(geoLocation.Latitude, geoLocation.Longitude));
            if (zoom != -1)
            {
                builder.Zoom(zoom);
            }
            else
            {
                builder.Zoom(map.CameraPosition.Zoom);
            }

            //builder.Bearing(155);
            //builder.Tilt(65);
            var cameraPosition = builder.Build();
            var cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);
        }
Beispiel #2
0
        public void OnMapReady(GoogleMap googleMap)
        {
            _googleMap = googleMap;
            _googleMap.UiSettings.ZoomControlsEnabled = true;
            _googleMap.UiSettings.CompassEnabled      = true;

            LatLng location = new LatLng(49.99181, 36.23572);

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(location);
            builder.Zoom(15);
            CameraPosition cameraPosition = builder.Build();

            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            _googleMap.MoveCamera(cameraUpdate);

            _markerOptions = new MarkerOptions();
            _markerOptions.Draggable(true);
            if (ViewModel.LalitudeGoogleMarker != 0)
            {
                _lalitude  = this.ViewModel.LalitudeGoogleMarker;
                _longitude = this.ViewModel.LongitudeGoogleMarker;
                _latLng    = new LatLng(_lalitude, _longitude);
                _markerOptions.SetPosition(_latLng);
                _googleMap.AddMarker(_markerOptions);
            }
            _googleMap.MapClick      += MapOptionsClick;
            _googleMap.MarkerDragEnd += MarkerOptionLongClick;

            this.ViewModel.LalitudeGoogleMarker  = _lalitude;
            this.ViewModel.LongitudeGoogleMarker = _longitude;
        }
        public void AddFromBitmap(View view)
        {
            if (hMap == null)
            {
                return;
            }
            if (null != overlay)
            {
                overlay.Remove();
            }
            Log.Debug(TAG, "AddFromBitmap: ");
            Drawable vectorDrawable = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.niuyouguo, null);
            Bitmap   bitmap         = Bitmap.CreateBitmap(vectorDrawable.IntrinsicWidth, vectorDrawable.IntrinsicHeight,
                                                          Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            vectorDrawable.SetBounds(0, 0, canvas.Width, canvas.Height);
            vectorDrawable.Draw(canvas);
            GroundOverlayOptions options = new GroundOverlayOptions().Position(MapUtils.FRANCE2, 50, 50)
                                           .InvokeImage(BitmapDescriptorFactory.FromBitmap(bitmap));

            overlay = hMap.AddGroundOverlay(options);
            CameraPosition cameraPosition = new
                                            CameraPosition.Builder().Target(MapUtils.FRANCE2).Zoom(18).Bearing(0f).Tilt(0f).Build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            hMap.MoveCamera(cameraUpdate);
        }
Beispiel #4
0
        public void OnMapReady(GoogleMap googleMap)
        {
            LatLng paris = new LatLng(48.857708, 2.346353);

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(paris);
            builder.Zoom(7);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            mMap = googleMap;

            if (mMap != null)
            {
                mMap.MoveCamera(cameraUpdate);
                mMap.MyLocationEnabled                  = false; //ne pas afficher le point bleu
                mMap.UiSettings.MapToolbarEnabled       = false; //ne pas afficher la redirection vers goggle map et navigation
                mMap.UiSettings.MyLocationButtonEnabled = false; // AFFICHER LE BOUTON GPS
            }

            if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != (int)Permission.Granted)
            {
                mMap.MyLocationEnabled = false;//ne pas afficher le point bleu
            }
            else
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
                {
                    RequestPermissions(new string[] { Manifest.Permission.AccessFineLocation }, RequestLocationId);
                }
            }
        }
        void HandlePaneStateChanged(InfoPane.State state)
        {
            if (map == null)
            {
                return;
            }
            var time    = Resources.GetInteger(Android.Resource.Integer.ConfigShortAnimTime);
            var enabled = state != InfoPane.State.FullyOpened;

            map.UiSettings.ScrollGesturesEnabled = enabled;
            map.UiSettings.ZoomGesturesEnabled   = enabled;
            if (state == InfoPane.State.FullyOpened && currentShownMarker != null)
            {
                oldPosition = map.CameraPosition;
                var destX        = mapFragment.Width / 2;
                var destY        = (mapFragment.Height - pane.Height) / 2;
                var currentPoint = map.Projection.ToScreenLocation(currentShownMarker.Position);
                var scroll       = CameraUpdateFactory.ScrollBy(-destX + currentPoint.X, -destY + currentPoint.Y);
                map.AnimateCamera(scroll, time, null);
            }
            else if (oldPosition != null)
            {
                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(oldPosition), time, null);
                oldPosition = null;
            }
        }
        private void NativeMapOnMyLocationChange(object sender, GoogleMap.MyLocationChangeEventArgs e)
        {
            if (e?.Location == null)
            {
                return;
            }

            if (Element is ResearchMap researchMap)
            {
                if (researchMap.CameraFollowsUser)
                {
                    var newLat  = e.Location.Latitude;
                    var newLong = e.Location.Longitude;
                    var bearing = e.Location.Bearing;

                    var cameraPositionBuilder = CameraPosition.InvokeBuilder();
                    cameraPositionBuilder.Target(new LatLng(newLat, newLong));
                    cameraPositionBuilder.Bearing(bearing);
                    cameraPositionBuilder.Zoom(researchMap.CameraZoom);

                    var cameraPosition = cameraPositionBuilder.Build();
                    var cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                    NativeMap.AnimateCamera(cameraUpdate);
                }
            }

            // Console.WriteLine($"ResearchMapRenderer: Lat={location.Latitude}, Long={location.Longitude}, Alt={location.Altitude}, Spd={location.Speed}, Acc={location.Accuracy}, Hdg={location.Bearing}");
        }
Beispiel #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
            GoogleMap   map     = mapFrag.Map;

            if (map != null)
            {
                LatLng location = new LatLng(-23.549852, -46.633935);

                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(location);
                builder.Zoom(16);

                CameraPosition cameraPosition = builder.Build();
                CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                map.MoveCamera(cameraUpdate);

                map.MyLocationEnabled = true;


                MarkerOptions markerOpt1 = new MarkerOptions();
                markerOpt1.SetPosition(new LatLng(-23.550368, -46.631725));
                markerOpt1.SetTitle("Ponto Central");
                map.AddMarker(markerOpt1);
            }
        }
Beispiel #8
0
        public void OnProgressChange(Location p0, RouteProgress p1)
        {
            var location      = p0;
            var routeProgress = p1;

            bool isInTunnel = routeProgress.InTunnel();

            lastLocation = location;
            if (!wasInTunnel && isInTunnel)
            {
                wasInTunnel = true;
                Snackbar.Make(contentLayout, "Enter tunnel!", Snackbar.LengthShort).Show();
            }
            if (wasInTunnel && !isInTunnel)
            {
                wasInTunnel = false;
                Snackbar.Make(contentLayout, "Exit tunnel!", Snackbar.LengthShort).Show();
            }
            if (tracking)
            {
                mapboxMap.LocationComponent.ForceLocationUpdate(location);
                CameraPosition cameraPosition = new CameraPosition.Builder()
                                                .Zoom(15)
                                                .Target(new LatLng(location.Latitude, location.Longitude))
                                                .Bearing(location.Bearing)
                                                .Build();
                mapboxMap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition), 2000);
            }
            instructionView.UpdateDistanceWith(routeProgress);
        }
Beispiel #9
0
        public void OnPlaceSelected(IPlace place)
        {
            IPlace lugar = place;

            direccion = place.AddressFormatted.ToString();
            latitud   = place.LatLng.Latitude;
            longitud  = place.LatLng.Longitude;
            //Mapa
            //Coordenadas del centro de Aguascalientes
            LatLng location = new LatLng(latitud, longitud);

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(location);
            builder.Zoom(18);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            //Mover la posición de la cámara
            _map.MoveCamera(cameraUpdate);
            //Agregar marcador
            markerOpt1 = new MarkerOptions();
            markerOpt1.SetPosition(location);
            markerOpt1.Draggable(true);
            _map.AddMarker(markerOpt1);
        }
Beispiel #10
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            this.ViewModel.InitialiseData();
            this.ViewModel.CheckValidity();

            await Task.Delay(500); // workaround for #30 [Android]Map.Pins.Add doesn't work when page OnAppearing

            var position = await LocationService.GetCurrentLocation(this.ViewModel);

            if (position == null)
            {
                return;
            }

            var pos = new Position(position.Latitude, position.Longitude);

            await this.MyMap.AnimateCamera(
                CameraUpdateFactory.NewCameraPosition(
                    new CameraPosition(
                        pos,
                        15d,
                        0d,
                        0d)),
                TimeSpan.FromSeconds(2));
        }
        public NuevoDesarrollo()
        {
            InitializeComponent();
            try
            {
                string estilo = "[{'elementType': 'geometry','stylers': [{'color': '#f5f5f5'}]},{'elementType': 'labels.icon','stylers': [{'visibility': 'off'}]},{'elementType': 'labels.text.fill','stylers': [{'color': '#616161'}]},{'elementType': 'labels.text.stroke','stylers': [{'color': '#f5f5f5'}]},{'featureType': 'administrative','elementType': 'geometry.stroke','stylers': [{'visibility': 'on'}]},{'featureType': 'administrative.land_parcel','elementType': 'labels.text.fill','stylers': [{'color': '#bdbdbd'}]},{'featureType': 'poi','elementType': 'geometry','stylers': [{'color': '#eeeeee'}]},{'featureType': 'poi','elementType': 'labels.text.fill','stylers': [{'color': '#757575'}]},{'featureType': 'poi.park','elementType': 'geometry','stylers': [{'color': '#e5e5e5'}]},{'featureType': 'poi.park','elementType': 'labels.text.fill','stylers': [{'color': '#9e9e9e'}]},{'featureType': 'road','elementType': 'geometry','stylers': [{'color': '#ffffff'}]},{'featureType': 'road.arterial','elementType': 'geometry.fill','stylers': [{'color': '#a9a9a9'}]},{'featureType': 'road.arterial','elementType': 'labels.text.fill','stylers': [{'color': '#757575'}]},{'featureType': 'road.highway','elementType': 'geometry','stylers': [{'color': '#dadada'}]},{'featureType': 'road.highway','elementType': 'geometry.fill','stylers': [{'color': '#941100'}]},{'featureType': 'road.highway','elementType': 'labels.text.fill','stylers': [{'color': '#616161'}]},{'featureType': 'road.local','elementType': 'geometry.fill','stylers': [{'color': '#d6d6d6'}]},{'featureType': 'road.local','elementType': 'labels.text.fill','stylers': [{'color': '#9e9e9e'}]},{'featureType': 'transit.line','elementType': 'geometry','stylers': [{'color': '#e5e5e5'}]},{'featureType': 'transit.station','elementType': 'geometry','stylers': [{'color': '#eeeeee'}]},{'featureType': 'water','elementType': 'geometry','stylers': [{'color': '#c9c9c9'}]},{'featureType': 'water','elementType': 'labels.text.fill','stylers': [{'color': '#9e9e9e'}]}]";
                mapa = new Map()
                {
                    HeightRequest = 150, InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition(new Position(20.673755, -103.376783), 10d, 0, 0))
                };
                mapcont1.Children.Add(mapa);
                mapa.MyLocationEnabled = true;
                mapa.MapStyle          = MapStyle.FromJson(estilo);
                mapa.UiSettings.MyLocationButtonEnabled = true;
                Color color1 = new Color();
                color1    = _colors[1].Item2;
                pincentro = new Pin()
                {
                    Label    = "Nuevo desarrollo",
                    Icon     = BitmapDescriptorFactory.DefaultMarker(color1),
                    Position = new Position(mapa.CameraPosition.Target.Latitude, mapa.CameraPosition.Target.Longitude),
                };
                mapa.Pins.Add(pincentro);

                mapa.CameraChanged += Mapa_CameraChanged;
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #12
0
        private async void OnAddressEntryUnfocused(object sender, FocusEventArgs e)
        {
            var entry = sender as Entry;

            if (entry == null)
            {
                return;
            }

            bool valid = await this.ViewModel.CheckAddressValidity();

            entry.TextColor = valid ? Color.FromHex("#646464")
                            : Color.FromHex("#CF000F");

            if (this.ViewModel.Point.Latitude != 0 ||
                this.ViewModel.Point.Longitude != 0)
            {
                this.CreatePin(this.ViewModel.Point);

                await this.MyMap.AnimateCamera(
                    CameraUpdateFactory.NewCameraPosition(
                        new CameraPosition(
                            this.ViewModel.Point,
                            15d,
                            0d,
                            0d)),
                    TimeSpan.FromSeconds(2));
            }

            this.ViewModel.CheckValidity();
        }
Beispiel #13
0
        public void OnMapReady(GoogleMap googleMap)
        {
            OnibusClass AcompanhaOnibus = new OnibusClass();
            DataRow     Onibus;
            string      PosX, PosY;
            Double      ValX, ValY;


            Onibus = AcompanhaOnibus.SelectOnibus(Convert.ToInt32(NumeroOnibus)).Rows[0];

            PosX = Onibus.ItemArray[2].ToString();
            PosY = Onibus.ItemArray[3].ToString();
            ValX = Convert.ToDouble(PosX);
            ValY = Convert.ToDouble(PosY);

            googleMap.UiSettings.ZoomControlsEnabled = true;
            googleMap.UiSettings.CompassEnabled      = true;
            new PontosClass().CarregaPontosMapa(googleMap);
            googleMap.MoveCamera(CameraUpdateFactory.ZoomIn());
            if (_currentLocation == null)
            {
                Gps();
                _currentLocation = _locationManager.GetLastKnownLocation(_ProviderGps);
            }
            googleMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(new
                                                                       CameraPosition(new LatLng(_currentLocation.Latitude, ValY), 35, 0, 0)));

            OnibusMark = googleMap.AddMarker(new MarkerOptions().SetPosition(new LatLng(ValX, _currentLocation.Longitude))
                                             .SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.bus)));
            Mapp = googleMap;
        }
Beispiel #14
0
        public void OnMapReady(GoogleMap googleMap)
        {
            this.map = googleMap;
            MapsInitializer.Initialize(Activity.ApplicationContext);
            clusterManager          = new ClusterManager(Context, map);
            clusterManager.Renderer = new MoyeuClusterRenderer(Context, map, clusterManager);
            map.SetOnCameraIdleListener(clusterManager);

            // Default map initialization
            if (ContextCompat.CheckSelfPermission(Activity, Android.Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                googleMap.MyLocationEnabled = true;
            }
            googleMap.UiSettings.MyLocationButtonEnabled = false;

            googleMap.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(Context, Resource.Raw.GMapStyle));

            googleMap.MarkerClick += HandleMarkerClick;
            googleMap.MapClick    += HandleMapClick;
            var oldPosition = PreviousCameraPosition;

            if (oldPosition != null)
            {
                googleMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(oldPosition));
            }
        }
Beispiel #15
0
        private static void UpdateCamera(Xamarin.Forms.GoogleMaps.Map map, Position pos)
        {
            CameraPosition cameraPosition = new CameraPosition(pos, 12, 10);
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.AnimateCamera(cameraUpdate);
        }
Beispiel #16
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Map);

            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            map = mapFrag.Map;

            if (map != null)
            {
                MarkerOptions opt1 = new MarkerOptions();

                double lat     = Convert.ToDouble(Intent.GetStringExtra("Latitude"));
                double lng     = Convert.ToDouble(Intent.GetStringExtra("Longitude"));
                string address = Intent.GetStringExtra("Address");

                LatLng location = new LatLng(lat, lng);
                opt1.SetPosition(location);
                opt1.SetTitle(address);
                map.AddMarker(opt1);

                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(location);
                builder.Zoom(15);

                CameraPosition cameraPosition = builder.Build();
                CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

                map.MoveCamera(cameraUpdate);
            }
        }
        private void SetCurrentPositionButton()
        {
            Button currentLocationButton = FindViewById <Button>(Resource.Id.currentLocationButton);

            currentLocationButton.Click += async(sender, e) =>
            {
                var locationService = GetLocationService();
                var location        = await locationService.GetLastLocationAsync();

                var latlng = new LatLng(location.Latitude, location.Longitude);

                if (_marker == null)
                {
                    MarkerOptions markerOptions = new MarkerOptions();
                    markerOptions.SetPosition(latlng);
                    markerOptions.SetTitle("Home");
                    _marker = _map.AddMarker(markerOptions);
                }
                else
                {
                    _marker.Position = latlng;
                }

                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(latlng);
                builder.Zoom(18);
                builder.Bearing(155);
                builder.Tilt(65);
                CameraPosition cameraPosition = builder.Build();
                _map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition));
            };
        }
Beispiel #18
0
        public void OnMapReady(GoogleMap googleMap)
        {
            map = googleMap;                          //set the created googleMap to the map variables
            map.UiSettings.CompassEnabled    = false; //disable compass
            map.UiSettings.MapToolbarEnabled = false; //disable map toolbar

            if (client.IsConnected)                   //if the client is still connected
            {
                LatLng position = new LatLng(myLocation.Latitude, myLocation.Longitude);
                userMarker = new MarkerOptions();
                userMarker.SetTitle("You")
                .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed))           //set the current position of the volunteer using a marker
                .SetPosition(position);
                CameraPosition cameraPosition = new CameraPosition.Builder().Target(position)
                                                .Zoom(15)
                                                .Tilt(45)
                                                .Build();
                userMark = map.AddMarker(userMarker); //add the marker on the map
                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition));
            }

            else
            {
                client.Reconnect(); //attempt to reconnect the client
            }
        }
        public void AddMarkers(List <Strike> strikeList)
        {
            foreach (var strike in strikeList)
            {
                if (strike.Lat != null && strike.Lon != null)
                {
                    var markerOpt1 = new MarkerOptions();
                    markerOpt1.SetPosition(new LatLng(strike.Lat.Value, strike.Lon.Value));
                    markerOpt1.SetTitle($"{strike.Country}, {strike.Date:dd MMMM, yyyy}");
                    Map.AddMarker(markerOpt1);
                }
            }

            var location = new LatLng(15, 48);
            var builder  = CameraPosition.InvokeBuilder();

            builder.Target(location);
            builder.Zoom(2);
            builder.Bearing(0);
            builder.Tilt(0);
            var cameraPosition = builder.Build();
            var cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            Map.MoveCamera(cameraUpdate);
        }
Beispiel #20
0
        private void finishBtnClicked()
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this.Context);
            builder.SetTitle("Complete Trip")
            .SetMessage("Are you sure you want to complete the trip?")
            .SetPositiveButton("Yes", (sender, e) =>
            {
                pairOneMark.Remove();
                pairTwoMark.Remove();
                poly.Remove();
                acceptedRequestLayout.Visibility = ViewStates.Gone;
                searchView.Visibility            = ViewStates.Visible;
                searchListView.Visibility        = ViewStates.Visible;
                clearSearchView();
                locationAdapter.Clear();
                svDescription.Visibility      = ViewStates.Visible;
                svDescription.Text            = "SEARCH FOR LOCATION";
                LatLng position               = new LatLng(myLocation.Latitude, myLocation.Longitude);
                CameraPosition cameraPosition = new CameraPosition.Builder().Target(position)
                                                .Zoom(15)
                                                .Tilt(45)
                                                .Build();
                map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(cameraPosition));
            }).SetNegativeButton("No", (sender, e) =>
            {
                //Do nothing
            });

            Dialog dialog = builder.Create();

            dialog.Show(); //show the dialog
        }
Beispiel #21
0
        public void OnMapReady(GoogleMap map)
        {
            var latLong = new LatLng(-6.1858248, 106.6141176);

            map.MapType = GoogleMap.MapTypeNormal;

            MarkerOptions marker = new MarkerOptions();

            marker.SetPosition(latLong);
            marker.SetTitle("JNE Tangerang");

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(latLong);
            builder.Zoom(18);
            builder.Bearing(155);
            builder.Tilt(65);

            CameraPosition cameraPosition = builder.Build();

            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);

            map.AddMarker(marker);
        }
        private async Task AddPinMap()
        {
            if (checkRegistro != null)
            {
                Plugin.Geolocator.Abstractions.Position pos = await compGPS.GetCurrentLocation();

                if (pos != null && pos.Latitude != 0 && pos.Longitude != 0)
                {
                    Position _position = new Position(pos.Latitude, pos.Longitude);

                    var MyPos = new Pin()
                    {
                        Position = _position,
                        Label    = "MINHA POSIÇÃO"
                    };
                    map.Pins.Clear();
                    map.Pins.Add(MyPos);
                    map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition(_position, 15D, 0d, 0d));
                    map.MoveToRegion(MapSpan.FromCenterAndRadius(MyPos.Position, Distance.FromMeters(2000)), true);
                }
                else
                {
                    map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition(new Position(-17.7920769, -50.9238804), 13D, 0d, 0d));
                }
            }
        }
        public MainMapViewModel(
            IRequestService requestService,
            ILayerService layerService,
            IGeolocatorService geolocatorService,
            INavigationService navigationService,
            IHexagonal hexagonal,
            IHeatGradientService heatGradientService,
            IZoneService zoneService)
        {
            _requestService      = requestService;
            _layerService        = layerService;
            _geolocatorService   = geolocatorService;
            _navigationService   = navigationService;
            _hexagonal           = hexagonal;
            _heatGradientService = heatGradientService;
            _zoneService         = zoneService;

            Initialized         = false;
            _layerLast          = 0;
            _currentPositionTag = String.Empty;
            _currentPosition    = _geolocatorService.LastRecordedPosition;
            //MainMapInitialCameraUpdate = CameraUpdateFactory.NewPositionZoom(_currentPosition, 12.0); // zoom can be within: [2,21]
            CameraPosition cp = new CameraPosition(_currentPosition, 12.0, 0.0, 60.0);

            MainMapInitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(cp);
        }
        public PlaceDetails(int id = 1)
        {
            InitializeComponent();

            placeID = id;
            Place p = CommentsModel.GetPlaceWithComments(id);

            BindingContext = new PlaceDetailsViewModel {
                BindedPlace = p
            };
            Title = ((PlaceDetailsViewModel)BindingContext)?.BindedPlace.title;

            ListComments.ItemsSource = p.comments;

            // Setting map properties to make it show the current place
            Position pos = new Position(p.latitude, p.longitude);

            map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(
                new CameraPosition(
                    pos,
                    13,
                    0,
                    0
                    )
                );

            Pin pin = new Pin();

            pin.Position = pos;
            pin.Label    = p.title;
            map.Pins.Add(pin);

            Constantes.authModel?.AutoRefreshToken();
        }
Beispiel #25
0
        public void OnMapReady(GoogleMap googleMap)
        {
            map = googleMap;

            if (map != null)
            {
                LatLng location = new LatLng(35.8, 128.6);
                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                builder.Target(location);
                builder.Zoom(10);
                map.MoveCamera(CameraUpdateFactory.NewCameraPosition(builder.Build()));

                clusterManager = new ClusterManager(Instance, map);

                clusterManager.SetOnClusterClickListener(Instance);
                clusterManager.SetOnClusterItemClickListener(Instance);
                clusterManager.Algorithm = new GridBasedAlgorithm();
                clusterManager.Renderer  = new TClusterRenderer(Instance, map, clusterManager);
                map.SetOnCameraIdleListener(clusterManager);
                map.SetOnMarkerClickListener(clusterManager);
                //35.858070, 128.624213
                for (int i = 0; i < 500; i++)
                {
                    addMarker(new LatLng(Java.Lang.Math.Random() / 10 + 35.8, Java.Lang.Math.Random() / 10 + 128.6));
                }
            }
        }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            mapFragment.Map.MyLocationEnabled = true;
            mapFragment.Map.UiSettings.MyLocationButtonEnabled = false;
            mapFragment.Map.MarkerClick += HandleMarkerClick;
            mapFragment.Map.MapClick    += HandleMapClick;
            var oldPosition = PreviousCameraPosition;

            if (oldPosition != null)
            {
                mapFragment.Map.MoveCamera(CameraUpdateFactory.NewCameraPosition(oldPosition));
            }

            // Setup info pane
            var bikeDrawable        = SvgFactory.GetDrawable(Resources, Resource.Raw.bike);
            var lockDrawable        = SvgFactory.GetDrawable(Resources, Resource.Raw.ic_lock);
            var stationLockDrawable = SvgFactory.GetDrawable(Resources, Resource.Raw.station_lock);
            var bikeNumberDrawable  = SvgFactory.GetDrawable(Resources, Resource.Raw.bike_number);
            var clockDrawable       = SvgFactory.GetDrawable(Resources, Resource.Raw.clock);

            starOnDrawable  = SvgFactory.GetDrawable(Resources, Resource.Raw.star_on);
            starOffDrawable = SvgFactory.GetDrawable(Resources, Resource.Raw.star_off);
            pane.FindViewById <ImageView> (Resource.Id.bikeImageView).SetImageDrawable(bikeDrawable);
            pane.FindViewById <ImageView> (Resource.Id.lockImageView).SetImageDrawable(lockDrawable);
            pane.FindViewById <ImageView> (Resource.Id.stationLock).SetImageDrawable(stationLockDrawable);
            pane.FindViewById <ImageView> (Resource.Id.bikeNumberImg).SetImageDrawable(bikeNumberDrawable);
            pane.FindViewById <ImageView> (Resource.Id.clockImg).SetImageDrawable(clockDrawable);
            var starBtn = pane.FindViewById <ImageButton> (Resource.Id.StarButton);

            starBtn.Click += HandleStarButtonChecked;
            streetViewFragment.StreetViewPanorama.UserNavigationEnabled    = false;
            streetViewFragment.StreetViewPanorama.StreetNamesEnabled       = false;
            streetViewFragment.StreetViewPanorama.StreetViewPanoramaClick += HandleMapButtonClick;
        }
Beispiel #27
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            await Task.Delay(100); // workaround for #30 [Android]Map.Pins.Add doesn't work when page OnAppearing

            Pin pin = new Pin()
            {
                Type     = PinType.Place,
                Label    = this.ViewModel.SelectedOwner.Name,
                Address  = this.ViewModel.SelectedOwner.Location.Address,
                Position = new Position(
                    this.ViewModel.SelectedOwner.Location.Latitude,
                    this.ViewModel.SelectedOwner.Location.Longitude),
                Icon = BitmapDescriptorFactory.DefaultMarker(Color.Orange),
                Flat = true
            };

            this.MyMap.Pins.Add(pin);

            await this.MyMap.AnimateCamera(
                CameraUpdateFactory.NewCameraPosition(
                    new CameraPosition(
                        pin.Position,
                        15d,
                        0d,
                        0d)),
                TimeSpan.FromSeconds(2));
        }
Beispiel #28
0
        public MapDetailView()
        {
            this.WhenActivated(d =>
            {
                this.WireUpControls();
                MapPosition.OnCreate(savedInstanceState);
                MapPosition.OnResume();
                MapsInitializer.Initialize(this);
                MapPosition.GetMapAsync(this);

                d(this.WhenAny(v => v.ViewModel.CurrentCoordinates, x => x.Value).Where(v => v != null).Subscribe(center =>
                {
                    LatLng location = new LatLng(center.Latitude, center.Longitude);
                    CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                    builder.Target(location);
                    builder.Zoom(18);
                    if (center.Heading > -1)
                    {
                        builder.Bearing((float)center.Heading / 360.0f);
                    }
                    builder.Tilt(65);
                    CameraPosition cameraPosition = builder.Build();
                    CameraUpdate cameraUpdate     = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                    map.MoveCamera(cameraUpdate);

                    MarkerOptions myPosition = new MarkerOptions();
                    myPosition.SetPosition(location);
                    myPosition.SetTitle("Aqui estamos!");
                    map.AddMarker(myPosition);
                }));
            });
        }
Beispiel #29
0
        private void CenterMap(Location loc)
        {
            Log.Debug("CenterMap", "CenterMap called...");
            if (mMap != null)
            {
                if (loc != null)
                {
                    CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                    builder.Target(new LatLng(loc.Latitude, loc.Longitude));
                    builder.Zoom(15);
                    CameraPosition camPos = builder.Build();

                    mMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(camPos));

                    new Thread(() => { if (activeMonsters.Count == 0)
                                       {
                                           for (int i = 0; i < 5; i++)
                                           {
                                               generateMonster();
                                           }
                                       }
                               }).Start();
                }
            }
            else
            {
                Log.Debug("CenterMap", "Map is null...");
            }
        }
Beispiel #30
0
        public void OnMapReady(GoogleMap map)
        {
            var mapOptions = new GoogleMapOptions()
                             .InvokeMapType(GoogleMap.MapTypeNormal)
                             .InvokeZoomControlsEnabled(false)
                             .InvokeCompassEnabled(true);

            var fragTx = FragmentManager.BeginTransaction();

            _mapFragment = MapFragment.NewInstance(mapOptions);
            fragTx.Add(Resource.Id.map_fragment_container, _mapFragment, "map");
            fragTx.Commit();

            var location = new LatLng(ViewModel.Latitude ?? 0, ViewModel.Longitude ?? 0);
            var builder  = CameraPosition.InvokeBuilder();

            builder.Target(location);
            builder.Zoom(18);

            var cameraPosition = builder.Build();
            var cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            map.MoveCamera(cameraUpdate);

            var markerOpt1 = new MarkerOptions();

            markerOpt1.SetPosition(location);
            markerOpt1.SetTitle(ViewModel.Title);
            map.AddMarker(markerOpt1);
        }