我正在尝试在 Windows 8 中创建一个可以定位用户位置的应用程序。为此,我有以下课程
public sealed partial class Cercano : CentrosCo.Common.LayoutAwarePage
{
Geolocator geo = null;
public Cercano()
{
this.InitializeComponent();
}
public async void button1_Click(
object sender, RoutedEventArgs e)
{
if (geo == null)
{
geo = new Geolocator();
}
IGeoposition pos = await geo.GetGeopositionAsync();
textLatitude.Text = "Latitude: " + pos.Coordinate.Latitude.ToString();
textLongitude.Text = "Longitude: " + pos.Coordinate.Longitude.ToString();
textAccuracy.Text = "Accuracy: " + pos.Coordinate.Accuracy.ToString();
}
在 IGeoposition 中得到错误:
Windows.Devices.Geolocation.IGeoposition 由于其保护级别而无法访问,
选择已在宣言中的位置...