I wrote a very simple application which just get the current location of the phone – longitude and latitude and prints them. The problem is I get NAN for both longitude and latitude. Here is my code:
private void button1_Click(object sender, RoutedEventArgs e) {
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
GeoPosition<GeoCoordinate> GC = new GeoPosition<GeoCoordinate>();
GC = watcher.Position;
double latitude = GC.Location.Latitude;
double longitude = GC.Location.Longitude;
textBlock1.Text = "longitude: " + longitude;
textBlock2.Text = "latitude: " + latitude;
}
Don’t remember the specifics.. But your GPS isn’t just always on and thus doesn’t know your location ALL the time.
You need to enable the GPS, and wait for it to get a lock (as said, I don’t remember exactly how to do it). Only then it has coordinates.