Hi All,
Refer below code to do the same.
public async static Task<string> FindLongitudeAndLatitude()
{
string latitude = string.Empty;
string longitude = string.Empty;
Geolocator oGeolocator = new Geolocator();
try
{
//Geoposition geoposition = await oGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10));
Geoposition geoposition = await oGeolocator.GetGeopositionAsync();
latitude = geoposition.Coordinate.Latitude.ToString("0.00");
longitude = geoposition.Coordinate.Longitude.ToString("0.00");
}
catch (Exception) { }
return latitude + " & " + longitude;
}
Refer below code to do the same.
public async static Task<string> FindLongitudeAndLatitude()
{
string latitude = string.Empty;
string longitude = string.Empty;
Geolocator oGeolocator = new Geolocator();
try
{
//Geoposition geoposition = await oGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10));
Geoposition geoposition = await oGeolocator.GetGeopositionAsync();
latitude = geoposition.Coordinate.Latitude.ToString("0.00");
longitude = geoposition.Coordinate.Longitude.ToString("0.00");
}
catch (Exception) { }
return latitude + " & " + longitude;
}
No comments:
Post a Comment