我编写了一个非常简单的应用程序,它只获取手机的当前位置——经度和纬度并打印出来。问题是我得到NAN
了经度和纬度。这是我的代码:
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;
}