首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 如何获取 平板电脑GPS数据

2014-01-12 
c#怎么获取 平板电脑GPS数据现在手里有一个lenovo miix2型号的平板,win8系统,现在想通过GPS定位获取相应的

c# 怎么获取 平板电脑GPS数据
现在手里有一个lenovo miix2型号的平板,win8系统,现在想通过GPS定位获取相应的坐标信息,求大神帮助。
[解决办法]



这个要在平板上装应用 然后时时发到电脑上。 或用Eclipse调试工具去取
win8.1求指教

应是这个了

http://msdn.microsoft.com/en-us/library/windows/desktop/bb760543(v=vs.85).aspx
[解决办法]
我在用这种方式

Geolocator geoloc = new Geolocator();
            Geoposition position = await geoloc.GetGeopositionAsync();//h获得地理坐标
            HttpClient httpClient = new HttpClient();
            HttpResponseMessage httpResult = await httpClient.GetAsync(String.Format("http://maps.google.com/maps/api/geocode/xml?latlng={0},{1}&language=zh-CN&sensor=false", position.Coordinate.Latitude, position.Coordinate.Longitude));
            var resss = await httpResult.Content.ReadAsStringAsync();
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(resss);
            var nr = xml.SelectNodes("GeocodeResponse").First();
            var v = nr.SelectNodes("result").OrderBy(d => 1).Skip(3).Take(1).ToList().First();
            var t = v.SelectNodes("formatted_address").First().InnerText;

[解决办法]

GeoCoordinateWatcher  watcher;     
  private void StartButton_Click(object sender, RoutedEventArgs e)     
        {     
            if (watcher == null)     
            {     
                //GeoPositionAccuracy.High定义定位的精度水平,Hight表示高     
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);     
                //表示定位更新频率,即设定门限值,频率高则耗电高,因为它随时需要定位新的方位     
                watcher.MovementThreshold = 20;     
                //状态改变事件,如数据改变,服务停止等     
watcher.StatusChanged  + =  new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);     
                //位置改变事件,如经度,纬度,海拔等     
watcher.PositionChanged  + =  new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);     
watcher.Start();     
            }     
        }     
void watcher_PositionChanged(object sender,     
 GeoPositionChangedEventArgs<GeoCoordinate> e)     
        {     
            Dispatcher.BeginInvoke(() =>      
            {     
                //获取纬度坐标     


                this.LatitudeTextBox.Text = e.Position.Location.Latitude.ToString();     
                //获取经度坐标     
                this.LongitudeTextBox.Text = e.Position.Location.Longitude.ToString();     
            });     
        }     
          
        void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)     
        {     
            Dispatcher.BeginInvoke(() =>     
                {     
                    StatusTextBox.Text = e.Status.ToString();     
                });     
        }  

热点排行