Hi,first than nothing, I dont speak English very much, so sorry for that.
I'm new in Xamarin, and I'm trying create a Project Xamarin Form and I'm having problems with the Map in my project. I have a component Map but I would like when my app start, the map be in the current position of device. I have severals days but nothing. I tryed this:
private async Task Button_ClickedAsync(object sender, EventArgs e){ var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; var location = await locator.GetPositionAsync(TimeSpan.FromTicks(10000)); Position position = new Position(location.Latitude, location.Longitude); MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromMiles(3)));
}
Please help me
Answers
If my memory serves there is a
Map.SetCenter
method you can call - providing your current GPS location.That will move the map to your current location.
I Don't find that method

@Miki93 Try this sample https://github.com/HoussemDellai/Xamarin-Forms-Maps-Sample
Sorry about that. The HERE map component has
.SetCenter
andSetZoomLevel
. The Google Map web API has.SetCenter
but the Xamarin map component doesn't have that command. Sorry - after a while all the different map API tend to blur together in my head.in that example is not used the "Geolocator" to localize the current position, but have things very interesting. very thanks.
Very thanks anyway Clint StLaurent
how to get latitude and longitude in xamarin forms for all platforms i use
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
but i got error in "timeoutMilliseconds:1000" it not acceptable in GetPositionAsync method.
Add this Nuget Package manager, It's completely free
Now, we need to add location permission to our projects
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION