Example #1
0
        public void SetLocation(double lat, double lng)
        {
            this.SetSingleLocation(lat, lng);
            selectedLocation = new EbGeoLocation(lat, lng);

            this.SetAddress(lat, lng);
        }
Example #2
0
        private async void SetCordinates()
        {
            try
            {
                bool hasPermission = await AppPermission.GPSLocation();

                if (!hasPermission)
                {
                    EbLog.Error("[location} permission revoked by user, failed to set dcurrent gps location");
                    Utils.Toast("Location permission revoked");
                    return;
                }

                Location current = await EbGeoLocationHelper.GetCurrentLocationAsync();

                if (current != null)
                {
                    Cordinates = new EbGeoLocation {
                        Latitude = current.Latitude, Longitude = current.Longitude
                    };
                    mapView.SetLocation(current.Latitude, current.Longitude);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
        }
Example #3
0
        public override void SetValue(object value)
        {
            if (value == null)
            {
                this.SetCordinates();
                return;
            }

            try
            {
                string[] cordinates = value.ToString().Split(CharConstants.COMMA);

                if (cordinates.Length >= 2)
                {
                    double lat = Convert.ToDouble(cordinates[0]);
                    double lng = Convert.ToDouble(cordinates[1]);

                    Cordinates = new EbGeoLocation {
                        Latitude = lat, Longitude = lng
                    };
                    mapView.SetLocation(lat, lng);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
                EbLog.Error(ex.StackTrace);
            }
        }
Example #4
0
        private async Task ShowMapFullScreen()
        {
            EbGeoLocation loc = new EbGeoLocation();

            if (Cordinates != null)
            {
                loc.Latitude  = Cordinates.Latitude;
                loc.Longitude = Cordinates.Longitude;
            }

            EbMapBinding binding = new EbMapBinding
            {
                Location      = loc,
                ResultCommand = new Command <EbGeoLocation>(async(obj) => await GetResult(obj))
            };

            await App.Navigation.NavigateModalByRenderer(new GeoMapView(binding));
        }
Example #5
0
        private async void PlacesList_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (e.Item == null)
            {
                return;
            }
            if (sender is ListView lv)
            {
                lv.SelectedItem = null;
            }

            GooglePlaceInfo place = (GooglePlaceInfo)e.Item;

            if (place != null)
            {
                try
                {
                    PickerTextLable.Text = place.Description;

                    GooglePlace placeDetails = await service.GetPlaceDetails(place.PlaceId);

                    EbGeoLocation cords = placeDetails?.GetCordinates();

                    if (cords != null)
                    {
                        cords.Address    = place.Description;
                        selectedLocation = cords;
                        this.SetSingleLocation(cords.Latitude, cords.Longitude);
                    }
                }
                catch (Exception ex)
                {
                    EbLog.Info("Failed to fetch place details");
                    EbLog.Error(ex.Message);
                }
            }
            this.HideSearch();
        }
Example #6
0
 private async Task GetResult(EbGeoLocation geoLocation)
 {
     Cordinates = geoLocation;
     mapView.SetLocation(Cordinates.Latitude, Cordinates.Longitude);
     await App.Navigation.PopModalByRenderer(true);
 }