public void SetLocation(double lat, double lng) { this.SetSingleLocation(lat, lng); selectedLocation = new EbGeoLocation(lat, lng); this.SetAddress(lat, lng); }
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); } }
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); } }
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)); }
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(); }
private async Task GetResult(EbGeoLocation geoLocation) { Cordinates = geoLocation; mapView.SetLocation(Cordinates.Latitude, Cordinates.Longitude); await App.Navigation.PopModalByRenderer(true); }