private void MoveMap(Position position) { var center = new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude); var span = new Xamarin.Forms.Maps.MapSpan(center, 0.005, 0.005);// 1 - oznacza ile stóp w lewo i w góre ustawia się mapa od lokalizacji locationsMap.MoveToRegion(span); }
public static async Task <string> GetAddressAsync(double latitude, double longitude) { var geocoder = new Geocoder(); var position = new Xamarin.Forms.Maps.Position(latitude, longitude); var possibleAddresses = await geocoder.GetAddressesForPositionAsync(position); var address = possibleAddresses?.ToArray()[1]; return(address); }
private void OnLineItemSelected() { if (SelectedItem != null) { var MapPosition = new Xamarin.Forms.Maps.Position(SelectedItem.Lat, SelectedItem.Long); Device.BeginInvokeOnMainThread(() => { Map.MoveToRegion(MapSpan.FromCenterAndRadius(MapPosition, Distance.FromMiles(1.0))); }); } }
public override async Task InitAsync(Line param) { if (param != null) { LineList = param.lineItems; int i = 1; foreach (var item in LineList) { item.BusStopName = "Przystanek " + i.ToString(); i++; } await Task.Factory.StartNew(async() => { Position pos; if (!LocationService.IsLocationAvailable()) { await App.Current.MainPage.DisplayAlert("Brak lokalizacji", "Proszę włączyć lokalizację GPS", "OK"); pos = new Position(52.588262, 19.67104); } else { pos = await LocationService.GetCurrentPosition(); } var MapPosition = new Xamarin.Forms.Maps.Position(pos.Latitude, pos.Longitude); Device.BeginInvokeOnMainThread(() => { var list = new List <Pin>(); foreach (var item in LineList) { var position = new Xamarin.Forms.Maps.Position(item.Lat, item.Long); int k = 1; list.Add(new Pin { Label = "Przystanek " + k.ToString(), Position = position, Address = item.TimeIN }); k++; } Map.Pins = list; Map.MoveToRegion(MapSpan.FromCenterAndRadius(MapPosition, Distance.FromMiles(1.0))); }); }); } }
private void MoveMap(Position position) { Xamarin.Forms.Maps.Position center = new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude); Xamarin.Forms.Maps.MapSpan mapSpan = new Xamarin.Forms.Maps.MapSpan(center, DEFAULT_LATITUDE_DEGREES, DEFAULT_LONGITUDE_DEGREES); travelsMap.MoveToRegion(mapSpan); }