【发布时间】:2014-07-18 21:25:48
【问题描述】:
我在使用 windows phone 时遇到问题,我正在查看地理定位器位置更改事件,我实例化并设置 GEOLOCATOR,如下所示:
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.MovementThreshold = 100; // The units are meters.
geolocator.PositionChanged += geolocator_PositionChanged;
我的 positionchanged 事件如下:
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
marker = (UserLocationMarker)this.FindName("UserLocationMarker");
if (marker != null)
{
marker.GeoCoordinate = args.Position.Coordinate.ToGeoCoordinate();
}
});
}
当我在模拟器中启动它时,PositionChanged 正确地被启动了 1 次,最后一个位置被输入到 TOOLS 函数中的位置中......但是我添加到定位工具中的任何后续 GEOPOINTS 都不会启动 positionchanged 方法....我不认为它是模拟器本身,就好像我在模拟器上启动地图并使用定位工具一样,它会在每次更新时正确更改用户位置。但是在我的代码中,我对 positionchanged 方法进行了调试,并且仅在应用程序启动时第一次调用它,仅此而已……一旦获得了地理位置,这就是她所写的一切……永远不会触发任何动作在定位工具中。
我的代码中没有任何内容会破坏地理定位器对象...但没有其他输入会触发它...我不知所措..任何对我遗漏或不理解的内容的帮助将不胜感激。在这一点上,我想知道工具包中的 UserLocationMarker 是否以某种方式破坏或删除了位置更改事件侦听器注册或其他东西。
【问题讨论】:
标签: windows-phone-8 location windows-phone-8.1