摘要
???? 在wince6.0中,要調用GPS模塊,其實是一件很容易的事情。
正文
??? 在wince6.0中,如果要調用GPS模塊,其實很簡單,微軟已經為我們做好了這一切,我們只需要在自己的解決方案中,添加對Microsoft.WindowsMobile.Samples.Location.dll的引用就可以了,然后獲取一個GPS的實例,如下:
static Gps _Gps = null;/// <summary>/// 獲取GPS設備/// </summary>public Gps GpsDevice{get{if (_Gps == null){lock (typeof(Gps)){if (_Gps == null){_Gps = new Gps();}}}return _Gps;}}
然后注冊LocationChanged的事件,打開GPS設備就可以了,如下:
GpsDevice.LocationChanged += new LocationChangedEventHandler(GpsDevice_LocationChanged);void GpsDevice_LocationChanged(object sender, LocationChangedEventArgs args){try{if (PdaServer.PDAServer.IsRun && PdaServer.PDAServer.GpsDevice.Opened){//經度double Longitude = args.Position.Longitude;//緯度double Latitude = args.Position.Latitude;if (Longitude > 0 && Latitude > 0){//上傳GPS}}}catch { }}
?
其他相關的屬性和方法見該dll。
相關下載:Microsoft.WindowsMobile.Samples.Location.rar