I want to get the latitude and longitude of current device location, here is my code that is not working. "coord.IsUnknown == false" always return true that's why i am not been able to get the latitude and longitude.
public partial class PoultryDirectory_HomeMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSingUp_Click(object sender, EventArgs e)
{
getLatLng();
}
private void getLatLng()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
GeoCoordinate coord = watcher.Position.Location;
if (coord.IsUnknown == false)
{
double lat = coord.Latitude;
double lng = coord.Longitude;
Console.WriteLine("Lat: {0}, Long: {1}",lat,lng);
}
else
{
Console.WriteLine("Unknown latitude and longitude.");
}
}
}