本文介绍了如何使用GeoCoordinateWatcher在Windows Phone中跟踪人的运动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
从一个特定的起点,我想使用Windows Phone 7中的GeoCoordinateWatcher跟踪人在经度,纬度和高度方面的运动
From a particular start point, I want to track a person's movement in terms of longitude, latitude and altitude using GeoCoordinateWatcher in windows phone 7
当那个人到达相同的起点(制作圆形或矩形之后)时,我想停止跟踪.
And when that person reaches to the same start point (after making circles or rectangles )I want to stop tracking.
有什么想法要实现吗?
推荐答案
using System.Device.Location;
//Class level variable
GeoCoordinateWatcher watcher;
//Load event of your page
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
if (watcher.Permission == GeoPositionPermission.Granted)
watcher.MovementThreshold = 20;
}
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.Start();
}
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
//1- Use e.Position.Location to identify the position
//By use of a simple boolean variable you can identify the first reading
//Store that reading and take decission given the new position
//2- When you want to stop monitoring simply call watcher.Stop();
}
确保WMAppManifest.xml文件中存在以下功能
Make sure the capability below is present in WMAppManifest.xml file
<Capability Name="ID_CAP_LOCATION"/>
这篇关于如何使用GeoCoordinateWatcher在Windows Phone中跟踪人的运动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!