C# 如何在Google AdMob for Windows phone 8中手动添加位置?

C# 如何在Google AdMob for Windows phone 8中手动添加位置?,c#,silverlight,windows-phone-8,admob,C#,Silverlight,Windows Phone 8,Admob,我只是尝试使用谷歌Admob来开发WP8 Silverlight应用程序 如何将位置手动添加到AdRequest类 我试过这种方法,但没用 Geoposition geoposition = new Geoposition(); 然后 我在创建Geopposition对象时出错,该对象表示“Windows.Devices.Geoplocation.Geopposition”类型没有定义构造函数 我哪里做错了?谢谢 您必须使用 Geolocator geolocator = new Geol

我只是尝试使用谷歌Admob来开发WP8 Silverlight应用程序

如何将位置手动添加到AdRequest类

我试过这种方法,但没用

  Geoposition geoposition = new Geoposition();
然后

我在创建Geopposition对象时出错,该对象表示“Windows.Devices.Geoplocation.Geopposition”类型没有定义构造函数

我哪里做错了?谢谢

您必须使用

Geolocator geolocator = new Geolocator();
Geoposition geoposition = await geolocator.GetGeopositionAsync
(
    maximumAge: TimeSpan.FromMinutes(5),
    timeout: TimeSpan.FromSeconds(10)
);
然后

AdRequest adRequest = new AdRequest();
adRequest.Location = geoposition.Coordinate;
请查看“为您服务”应用程序,以便在执行此操作之前能够检测到用户的位置

AdRequest adRequest = new AdRequest();
adRequest.Location = geoposition.Coordinate;