本文介绍了GeoCoordinateWatcher() 在真正的 Windows 手机设备中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了获取纬度和经度,我编写了以下代码行.
For getting Latitude and Longitude i wrote the following line of code.
watcher = new GeoCoordinateWatcher();
var myPosition = myWatcher.Position;
if (!myPosition.Location.IsUnknown)
{
latitude = myPosition.Location.Latitude;
longitude = myPosition.Location.Longitude;
}
但是我得到的所有值都是 NAN .请告诉我如何在真实设备中获取当前的纬度和经度?
But i am getting all values as NAN .Please tell me how to get current latitude and longitude in real device?
推荐答案
您是否启动了观察程序?您也可以在模拟器上模拟 GPS.有一个工具可以做到这一点.
Have you started the watcher?Also you can simulate the GPS on emulator. There's a tool for that.
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
watcher.Start();
GeoCoordinate coord = watcher.Position.Location;
if (coord.IsUnknown != true)
{
Console.WriteLine("Lat: {0}, Long: {1}",
coord.Latitude,
coord.Longitude);
}
else
{
Console.WriteLine("Unknown latitude and longitude.");
}
这篇关于GeoCoordinateWatcher() 在真正的 Windows 手机设备中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!