Example #1
0
        internal bool SendMyLocationClicked()
        {
            var args = new MyLocationButtonClickedEventArgs();

            MyLocationButtonClicked?.Invoke(this, args);
            return(args.Handled);
        }
Example #2
0
        // My location button draw current marker
        async void Handle_MyLocationButtonClicked(object sender, Xamarin.Forms.GoogleMaps.MyLocationButtonClickedEventArgs e)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                if (CrossGeolocator.IsSupported && CrossGeolocator.Current.IsGeolocationEnabled)
                {
                    var locator = CrossGeolocator.Current;
                    locator.DesiredAccuracy = 50;

                    var location = await locator.GetPositionAsync(new TimeSpan(0, 0, 6));

                    if (location != null)
                    {
                        var context = BindingContext as AgendaPageModel;

                        if (Map.Pins.Contains(MyPin))
                        {
                            Map.Pins.Remove(MyPin);
                        }


                        Map.Pins.Add(MyPin = new Pin()
                        {
                            Address     = "",
                            IsDraggable = false,
                            Flat        = true,
                            Label       = "Current Location",
                            Type        = PinType.SavedPin,
                            IsVisible   = true,
                            Icon        = BitmapDescriptorFactory.FromView(new BindingPinView("Me", Color.Transparent)),
                            Position    = new Position(location.Latitude, location.Longitude)
                        });

                        await Map.AnimateCamera(CameraUpdateFactory.NewPositionZoom(new Position(location.Latitude, location.Longitude), 12), new TimeSpan(0, 0, 3));
                    }

                    await locator.StopListeningAsync();
                }
                else
                {
                    var response = await DisplayAlert(AppResources.Alert, AppResources.LocationEnableAlert, AppResources.Ok, AppResources.NotNow);
                }
            }
            catch (Exception)
            {
            }

            IsBusy = false;
        }
Example #3
0
        private async void OnMapMyLocationButtonClicked(object sender, Xamarin.Forms.GoogleMaps.MyLocationButtonClickedEventArgs e)
        {
            var position = await LocationService.GetCurrentLocation(this.ViewModel);

            if (position == null)
            {
                return;
            }

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

            CreatePin(pos);

            this.MyMap.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                    pos,
                    Distance.FromMeters(
                        MAP_SPAN_RADIUS)));
        }
Example #4
0
 // Redirect Button clicked
 void MyLocationButtonClicked(object sender, Xamarin.Forms.GoogleMaps.MyLocationButtonClickedEventArgs e)
 {
     // Direct map to the user location
     RedirectMapToLocation("User");
 }
Example #5
0
 void MyLocationButtonClicked(object sender, Xamarin.Forms.GoogleMaps.MyLocationButtonClickedEventArgs e)
 {
     RedirectMapToPinLocation();
 }
Example #6
0
 void Handle_MyLocationButtonClicked(object sender, Xamarin.Forms.GoogleMaps.MyLocationButtonClickedEventArgs e)
 {
     MoveToCurrentLocation();
 }
 /*Handle the my location button clicked event*/
 private void MyLocationButton_Clicked(object sender, GoogleMaps.MyLocationButtonClickedEventArgs e)
 {
     Current.UpdateCamera = true;
 }