Beispiel #1
0
        /// <summary>
        /// Adds a marker to the map
        /// </summary>
        /// <param name="pin">The Forms Pin</param>
        private async void AddPin(TKCustomMapPin pin)
        {
            pin.PropertyChanged += OnPinPropertyChanged;

            var markerWithIcon = new MarkerOptions();

            markerWithIcon.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));

            if (!string.IsNullOrWhiteSpace(pin.Title))
            {
                markerWithIcon.SetTitle(pin.Title);
            }
            if (!string.IsNullOrWhiteSpace(pin.Subtitle))
            {
                markerWithIcon.SetSnippet(pin.Subtitle);
            }

            await this.UpdateImage(pin, markerWithIcon);

            markerWithIcon.Draggable(pin.IsDraggable);
            markerWithIcon.Visible(pin.IsVisible);
            if (pin.Image != null)
            {
                markerWithIcon.Anchor((float)pin.Anchor.X, (float)pin.Anchor.Y);
            }

            this._markers.Add(pin, this._googleMap.AddMarker(markerWithIcon));
        }
Beispiel #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SecondView);

            var viewModel = (SecondViewModel)ViewModel;

            var mapFragment = (SupportMapFragment)SupportFragmentManager.FindFragmentById(Resource.Id.map);

            var options = new MarkerOptions();

            options.SetPosition(new LatLng(viewModel.Han.Location.Lat, viewModel.Han.Location.Lng));
            options.SetTitle("Han");
            options.Draggable(true);
            var hanMarker = mapFragment.Map.AddMarker(options);

            _han = new MarkerWrapper(hanMarker);

            mapFragment.Map.MarkerDragEnd += (sender, args) =>
            {
                _han.FirePositionChangedFromMap();
            };

            var set = this.CreateBindingSet <SecondView, SecondViewModel>();

            set.Bind(_han)
            .For(m => m.Position)
            .To(vm => vm.Han.Location)
            .WithConversion(new LocationToLatLngValueConverter(), null);
            set.Apply();
        }
Beispiel #3
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 #4
0
        private void InicializarMapa()
        {
            _customMap.MoveToRegion(_customMap.Posicao);

            //Buraco Marker.
            var buracoPin = new MarkerOptions();

            buracoPin.SetPosition(new LatLng(_customMap.BuracoPinPosicao.Latitude, _customMap.BuracoPinPosicao.Longitude));
            buracoPin.SetTitle("Buraco");
            _buracoMarker = _mapa.AddMarker(buracoPin);

            //Tee Marker.
            var teePin = new MarkerOptions();

            teePin.SetPosition(new LatLng(_customMap.TeePinPosicao.Latitude, _customMap.TeePinPosicao.Longitude));
            teePin.Draggable(true);
            teePin.SetTitle("Tee");
            _teeMarker           = _mapa.AddMarker(teePin);
            _teeMarker.Draggable = false;

            //Meio Marker.
            var meioPin = new MarkerOptions();

            meioPin.SetPosition(new LatLng(_customMap.MeioPinPosicao.Latitude, _customMap.MeioPinPosicao.Longitude));
            meioPin.Draggable(true);
            meioPin.SetTitle("Meio");
            _meioMarker = _mapa.AddMarker(meioPin);

            _mapa.MarkerDrag += _mapa_MarkerDrag;
        }
Beispiel #5
0
        public void OnMapReady(GoogleMap map)
        {
            _map = map;
            _map.UiSettings.ZoomControlsEnabled = true;
            _map.UiSettings.CompassEnabled      = true;
            _map.UiSettings.SetAllGesturesEnabled(true);

            LatLng        position = new LatLng(48.8833, 2.4667);
            MarkerOptions options  = new MarkerOptions();

            options.Draggable(true);
            options.SetTitle("Ma position");
            options.SetPosition(position);
            _marker = new MarkerWrapper(_map.AddMarker(options));
            _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(position, 15));

            _map.MarkerDrag += (sender, args) =>
            {
                _marker.FirePositionChanged();
            };

            var set = this.CreateBindingSet <MapView, MapViewModel>();

            set.Bind(_marker).For(m => m.Position).To(vm => vm.Location).WithConversion(new LocationToLatLngConverter(), null).TwoWay();
            set.Apply();
        }
Beispiel #6
0
        protected override Marker CreateNativeItem(Pin item)
        {
            MarkerOptions options = new MarkerOptions()
                                    .InvokePosition(item.Coordinate.ToNative())
                                    .InvokeTitle(item.Title);

            if (item.Animate)
            {
                options.InvokeAnimateType(MarkerOptions.MarkerAnimateType.Grow);
            }

            options.Draggable(item.Draggable);
            options.Flat(!item.Enabled3D);

            BitmapDescriptor bitmap = item.Image?.ToNative();

            if (null == bitmap)
            {
                throw new Exception("必须提供一个图标");
            }
            options.InvokeIcon(bitmap);

            Marker marker = (Marker)NativeMap.Map.AddOverlay(options);

            item.NativeObject = marker;

            return(marker);
        }
        /// <summary>
        /// initializes the <see cref="MarkerOptions"/>
        /// </summary>
        /// <param name="markerOptions">Instance of the marker options</param>
        /// <param name="setPosition">if <value>true</value>, the position will be updated</param>
        /// <returns><see cref="Task"/></returns>
        public async Task InitializeMarkerOptionsAsync(MarkerOptions markerOptions, bool setPosition = true)
        {
            if (setPosition)
            {
                markerOptions.SetPosition(new LatLng(Pin.Position.Latitude, Pin.Position.Longitude));
            }

            if (!string.IsNullOrWhiteSpace(Pin.Title))
            {
                markerOptions.SetTitle(Pin.Title);
            }
            if (!string.IsNullOrWhiteSpace(Pin.Subtitle))
            {
                markerOptions.SetSnippet(Pin.Subtitle);
            }

            await UpdateImageAsync(markerOptions);

            markerOptions.Draggable(Pin.IsDraggable);
            markerOptions.Visible(Pin.IsVisible);
            markerOptions.SetRotation((float)Pin.Rotation);
            if (Pin.Image != null)
            {
                markerOptions.Anchor((float)Pin.Anchor.X, (float)Pin.Anchor.Y);
            }
        }
        protected override void OnMapReady(GoogleMap googleMap)
        {
            base.OnMapReady(googleMap);
            _googleMap = googleMap;
            _googleMap.UiSettings.ZoomControlsEnabled     = true;
            _googleMap.UiSettings.CompassEnabled          = true;
            _googleMap.UiSettings.ZoomGesturesEnabled     = true;
            _googleMap.UiSettings.ScrollGesturesEnabled   = true;
            _googleMap.UiSettings.MyLocationButtonEnabled = true;

            if (ActivityCompat.CheckSelfPermission(Android.App.Application.Context, Manifest.Permission.AccessFineLocation) == (Android.Content.PM.Permission.Denied) ||
                ActivityCompat.CheckSelfPermission(Android.App.Application.Context, Manifest.Permission.AccessCoarseLocation) == (Android.Content.PM.Permission.Denied))
            {
                GetPermissionAsync();
                System.Threading.Thread.Sleep(5000);
            }
            _googleMap.MyLocationEnabled = true;
            _markerOptions = new MarkerOptions();
            _markerOptions.Draggable(true);
            if (_customMap.UserLalitude != 0 & _customMap.UserLongitude != 0)
            {
                _lalitude  = _customMap.UserLalitude;
                _longitude = _customMap.UserLongitude;
                _latLng    = new LatLng(_lalitude, _longitude);
                _marker    = _googleMap.AddMarker(new MarkerOptions().SetPosition(_latLng));
            }

            _googleMap.MapClick      += MapOptionsClick;
            _googleMap.MarkerDragEnd += MarkerOptionLongClick;
        }
Beispiel #9
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
            {
                NativeMap.Clear();
                NativeMap.InfoWindowClick += OnInfoWindowClick;
                NativeMap.SetInfoWindowAdapter(this);

                foreach (var pin in customPins)
                {
                    var marker = new MarkerOptions();
                    marker.SetPosition(new LatLng(pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
                    marker.SetTitle(pin.Pin.Label);
                    marker.SetSnippet(pin.Pin.Address);
                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.pin));
                    marker.Draggable(true);
                    //  NativeMap.MapClick += NativeMap_MapClick;
                    NativeMap.MarkerDragEnd   += NativeMap_MarkerDragEnd;
                    NativeMap.MarkerDragStart += NativeMap_MarkerDragStart;
                    NativeMap.AddMarker(marker);
                }
                isDrawn = true;
            }
        }
Beispiel #10
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;
        }
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            try
            {
                var place = Autocomplete.GetPlaceFromIntent(data);
                //getting location of the searched place
                var loc = place.LatLng;

                //creating camera update options to move camera to the searched location
                CameraUpdate cam = CameraUpdateFactory.NewLatLngZoom(loc, 17);

                //create marker options
                MarkerOptions markerOption = new MarkerOptions();
                markerOption.SetPosition(loc);
                markerOption.Draggable(true);
                int id0 = (int)typeof(Resource.Drawable).GetField("locationpoint").GetValue(null);
                BitmapDescriptor bmd0 = BitmapDescriptorFactory.FromResource(id0);
                markerOption.SetIcon(bmd0);
                //googleMap.Clear();
                googleMap.AddMarker(markerOption);
                googleMap.MoveCamera(cam);
                googleMap.MarkerDragEnd += GoogleMap_MarkerDragEnd1;
            }
            catch (Exception e)
            {
            }
        }
        public static MarkerOptions CreateUserDraggable(LatLng position)
        {
            MarkerOptions mo = new MarkerOptions();

            mo.SetPosition(position);
            mo.Draggable(true);

            return(mo);
        }
        public void OnMapReady(GoogleMap googleMap)
        {
            if (googleMap != null)
            {
                //Map is ready for use
                _map = googleMap;

                if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Permission.Granted)
                {
                    _map.MyLocationEnabled              = true;
                    _map.UiSettings.CompassEnabled      = true;
                    _map.UiSettings.ZoomControlsEnabled = true;

                    _map.MarkerDragEnd += myMarkerDragEnd;


                    CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                    LatLng location = null;
                    if ((lat != "") && (lon != ""))
                    {
                        location = new LatLng(GCStuffs.ConvertToDouble(lat), GCStuffs.ConvertToDouble(lon));
                    }
                    else
                    {
                        // Don't forget to assign a value to lat and lon
                        // If omeone click on save coord without moving the marker, these values will be used
                        lat      = "43.3";
                        lon      = "5.4";
                        location = new LatLng(43.3, 5.4);
                    }
                    builder.Target(location);
                    builder.Zoom(10);// 13);
                    CameraPosition cameraPosition = builder.Build();
                    CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                    _map.MoveCamera(cameraUpdate);

                    // Create marker
                    _marker = new MarkerOptions();
                    _marker.SetPosition(location);
                    TextView lblCoord = FindViewById <TextView>(Resource.Id.lblCoord);
                    lblCoord.Text = /*"DD° MM.MMM: " + */ NiceCoordToString(location);
                    _marker.Draggable(true);
                    _marker.SetTitle(NiceCoordToString(location));
                    //_marker.SetIcon(BitmapDescriptorFactory.FromResource(geo.GetIconResourceId()));
                    _map.AddMarker(_marker);

                    // Create circle if possible
                    CreateCircle(location);
                }
                else
                {
                    // Show rationale and request permission.
                    Toast.MakeText(this, this.Resources.GetString(Resource.String.ErrorLocation), ToastLength.Short).Show();
                }
            }
        }
Beispiel #14
0
        public MarkLocationOnMap(GoogleMap mMap, string title, string snippet, LatLng pos)
        {
            var marker = new MarkerOptions();

            marker.SetTitle(title);
            marker.SetSnippet(snippet);
            marker.Draggable(true);
            marker.SetPosition(pos);
            mMap.AddMarker(marker);
        }
        void ClickingMap(object sender, GoogleMap.MapClickEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Clicked on the map");
            var marker = new MarkerOptions();

            marker.Draggable(true);
            marker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));

            NativeMap.AddMarker(marker);
        }
        public static MarkerOptions CreateUserDragable()
        {
            MarkerOptions mo       = new MarkerOptions();
            LatLng        position = new LatLng(ConfigManager.DefaultLatMap, ConfigManager.DefaultLongMap);

            mo.SetPosition(position);
            mo.Draggable(true);

            return(mo);
        }
Beispiel #17
0
        private MarkerOptions CreateMarkerFromPCLPin(Pin customPin)
        {
            var markerIcon = new MarkerOptions();

            markerIcon.SetPosition(new LatLng(customPin.Position.Latitude, customPin.Position.Longitude));
            markerIcon.SetTitle(customPin.Label);
            markerIcon.SetSnippet(customPin.Address);
            markerIcon.Draggable(false);

            return(markerIcon);
        }
        void ClickingLongMap(object sender, GoogleMap.MapLongClickEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Clicked looogly on the map");
            var marker = new MarkerOptions();

            marker.Draggable(true);
            marker.SetPosition(new LatLng(e.Point.Latitude, e.Point.Longitude));
            formsMap.MarkerPosition = new Position(marker.Position.Latitude, marker.Position.Longitude);
            System.Diagnostics.Debug.WriteLine("pin starting latitude" + e.Point.Latitude);


            NativeMap.AddMarker(marker);
        }
Beispiel #19
0
        protected override MarkerOptions CreateMarker(Pin pin)
        {
            var mapPin = pin as CoworkingPin;
            var marker = new MarkerOptions();

            marker.SetPosition(new LatLng(mapPin.Position.Latitude, mapPin.Position.Longitude));
            marker.SetTitle(mapPin.Label);
            marker.SetSnippet(mapPin.Address);
            //marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.Pin));
            marker.Draggable(true);

            return(marker);
        }
Beispiel #20
0
        private void AddMarker(Marker marker)
        {
            if (marker is Polyline)
            {
                AddPolyline(marker as Polyline);
                return;
            }

            MarkerOptions options = new MarkerOptions();

            if (marker.ZIndex.HasValue)
            {
                options.InvokeZIndex(marker.ZIndex.Value);
            }
            options.SetPosition(new LatLng(marker.Center.Latitude, marker.Center.Longitude));

            if (!string.IsNullOrEmpty(marker.Icon))
            {
                if (imageResolver != null)
                {
                    System.IO.Stream stream = imageResolver.Resolve(marker.Layer, marker.Icon);
                    if (stream == null)
                    {
                        stream = imageResolver.Resolve(marker);
                    }
                    if (stream != null)
                    {
                        options.SetIcon(BitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(stream)));
                    }
                }
                else
                {
                    options.SetIcon(BitmapDescriptorFactory.FromResource(ResourceManager.GetDrawableByName(marker.Icon)));
                }
                if (marker.Label != null)
                {
                    CreateLabel(marker);
                }
            }

            options.SetTitle(marker.Title);
            options.SetSnippet(marker.Content);
            options.Draggable(marker.Draggable);

            markers.Add(marker, googleMap.AddMarker(options));

            marker.PropertyChanged += Marker_PropertyChanged;
        }
        //search button
        private async void Srch_button_Click(object sender, EventArgs e)
        {
            List <Location> loca = new List <Location>();

            loca = (List <Location>) await Geocoding.GetLocationsAsync(srch_text.Text);

            var           loc        = loca[0];
            LatLng        latlng_src = new LatLng(loc.Latitude, loc.Longitude);
            MarkerOptions mo         = new MarkerOptions();

            mo.SetPosition(latlng_src);
            mo.Draggable(true);

            googleMap.AddMarker(mo);
            CameraUpdate camup = CameraUpdateFactory.NewLatLngZoom(latlng_src, 17);

            googleMap.MoveCamera(camup);
        }
Beispiel #22
0
        public void OnMapReady(GoogleMap googleMap)
        {
            _map = googleMap;
            MarkerOptions markerOptions = new MarkerOptions();

            markerOptions.SetPosition(new LatLng(16.03, 108));
            markerOptions.SetTitle("test");
            markerOptions.Draggable(true);
            markerOptions.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_location_on_green_light_36dp));
            _map.AddMarker(markerOptions);
            //zoom
            _map.UiSettings.ZoomControlsEnabled = true;
            _map.UiSettings.CompassEnabled      = true;
            _map.MoveCamera(CameraUpdateFactory.ZoomIn());
            if (_map != null)
            {
                _map.MapType = GoogleMap.MapTypeNormal;
            }
        }
Beispiel #23
0
        public void OnMapReady(GoogleMap mapp)
        {
            googleMap = mapp;

            mapp.UiSettings.MyLocationButtonEnabled = true;

            googleMap.MapType = GoogleMap.MapTypeNormal;

            MarkerOptions m = new MarkerOptions();

            m.SetPosition(issuePosition);
            m.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
            m.Draggable(false);


            googleMap.AddMarker(m);
            CameraUpdate c = CameraUpdateFactory.NewLatLngZoom(issuePosition, 17);

            googleMap.AnimateCamera(c);
        }
Beispiel #24
0
        public void OnMapReady(GoogleMap googleMap)
        {
            _googleMap = googleMap;
            _googleMap.UiSettings.ZoomControlsEnabled = true;
            _googleMap.UiSettings.CompassEnabled      = true;

            if (ActivityCompat.CheckSelfPermission(Application.Context, Manifest.Permission.AccessFineLocation) == (Android.Content.PM.Permission.Denied) ||
                ActivityCompat.CheckSelfPermission(Application.Context, Manifest.Permission.AccessCoarseLocation) == (Android.Content.PM.Permission.Denied))
            {
                GetLocationPermission();
                System.Threading.Thread.Sleep(5000);
            }
            _googleMap.MyLocationEnabled = 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.LalitudeMarker != 0 & ViewModel.LongitudeMarker != 0)
            {
                _lalitude  = this.ViewModel.LalitudeMarker;
                _longitude = this.ViewModel.LongitudeMarker;
                _latLng    = new LatLng(_lalitude, _longitude);
                _marker    = _googleMap.AddMarker(new MarkerOptions().SetPosition(_latLng));
            }

            _googleMap.MapClick      += MapOptionsClick;
            _googleMap.MarkerDragEnd += MarkerOptionLongClick;

            this.ViewModel.LalitudeMarker  = _lalitude;
            this.ViewModel.LongitudeMarker = _longitude;
        }
Beispiel #25
0
        public void OnMapReady(GoogleMap map)
        {
            _map = map;
            _map.MarkerDragEnd += MarkerDragEnd;
            //Coordenadas del centro de Aguascalientes
            LatLng location = new LatLng(21.880636, -102.297108);

            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(new LatLng(21.880636, -102.297108));
            markerOpt1.Draggable(true);
            _map.AddMarker(markerOpt1);
        }
Beispiel #26
0
        public void OnMapReady(GoogleMap map)
        {
            map.MapType = GoogleMap.MapTypeTerrain;

            map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(46.0774, 18.6222), 5.9f));



            events = Event.GetAll().Where(x => x.startdate > DateTime.Now).ToArray();

            foreach (Event item in events)
            {
                MarkerOptions markerOpt = new MarkerOptions();
                markerOpt.SetPosition(new LatLng(item.lat, item.lon));
                markerOpt.SetTitle(item.game);
                markerOpt.SetSnippet(item.startdate.ToString("yyyy-MM-dd"));
                markerOpt.Draggable(true);
                map.MarkerDragStart += Map_MarkerDragStart;
                map.AddMarker(markerOpt);
            }
        }
Beispiel #27
0
        public void OnMapReady(GoogleMap googleMap)
        {
            epMap = googleMap;



            LatLng       latlng = new LatLng(requestedEvent.Latitude, requestedEvent.Longitude);
            CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);

            epMap.MoveCamera(camera);
            //place a pin where the event is located
            MarkerOptions options = new MarkerOptions().SetPosition(latlng).
                                    SetTitle(requestedEvent.Name).SetSnippet(requestedEvent.Details);

            if (requestedEvent.Username == userName)
            {
                options.Draggable(true);
            }

            epMap.AddMarker(options);
            //epMap.SetOnMapLongClickListener(this);
        }
Beispiel #28
0
        private async void Cargar_ubicacion(int id)
        {
            Manboss_clientes_direccion direccion = await core.Get_Direccion(id);

            //Coordenadas del centro de Aguascalientes
            LatLng location = new LatLng(direccion.Latitud, direccion.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(new LatLng(direccion.Latitud, direccion.Longitud));
            markerOpt1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.mandado));
            markerOpt1.Draggable(true);
            _map.AddMarker(markerOpt1);
        }
        public async void OnMapReady(GoogleMap mapp)
        {
            googleMap         = mapp;
            googleMap.MapType = GoogleMap.MapTypeNormal;

            var location = await Geolocation.GetLocationAsync(new GeolocationRequest
            {
                DesiredAccuracy = GeolocationAccuracy.Medium,
                Timeout         = TimeSpan.FromSeconds(10)
            });

            if (location != null)
            {
                LatLng loc  = new LatLng(location.Latitude, location.Longitude + 0.002);
                LatLng loc1 = new LatLng(location.Latitude, location.Longitude);

                CameraUpdate  cam = CameraUpdateFactory.NewLatLngZoom(loc, 17);
                MarkerOptions m   = new MarkerOptions();
                m.Draggable(true);
                m.SetPosition(loc);
                int id0 = (int)typeof(Resource.Drawable).GetField("locationpoint").GetValue(null);
                BitmapDescriptor bmd0 = BitmapDescriptorFactory.FromResource(id0);
                m.SetIcon(bmd0);


                MarkerOptions mo2 = new MarkerOptions();
                mo2.SetPosition(loc1);
                int id = (int)typeof(Resource.Drawable).GetField("locationpin").GetValue(null);
                BitmapDescriptor bmd = BitmapDescriptorFactory.FromResource(id);
                mo2.SetIcon(bmd);



                googleMap.MoveCamera(cam);
                googleMap.AddMarker(m);
                googleMap.AddMarker(mo2);
                googleMap.MarkerDragEnd += GoogleMap_MarkerDragEnd;
            }
        }
Beispiel #30
0
        protected override void OnMapReady(GoogleMap map)
        {
            if (mapDrawn)
            {
                return;
            }
            base.OnMapReady(map);

            NativeMap.SetInfoWindowAdapter(this);

            NativeMap.MarkerClick     += OnMarkerClick;
            NativeMap.InfoWindowClick += OnInfoWindowClick;

            pins                  = new List <Pin>(formsMap.Pins);
            CoworkingClicked     += formsMap.OnCoworking;
            formsMap.PinsUpdated += OnPinsUpdate;

            bool isEnabled = DependencyService.Get <IPermissionRequester>().IsGPSEnabled();

            if (me != null)
            {
                me.Remove();
            }

            if (isEnabled)
            {
                var ret    = LocationHelper.GetLocation();
                var marker = new MarkerOptions();
                marker.SetPosition(new LatLng(ret.Latitude, ret.Longitude));

                var bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.HereIcon);
                marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateScaledBitmap(bitmap, 350, 200, false)));
                marker.Draggable(false);
                me = NativeMap.AddMarker(marker);
            }

            mapDrawn = true;
        }