public void LocationsUpdated(CLLocationManager manager, CLLocation[] locations) { var location = locations.LastOrDefault(); if (location != null) { // altitudeLabel.Text = $"{location.Altitude} meters"; // lblLongitude.Text = "Lng:{0}º".FormatWith(location.Coordinate.Longitude); // lblLatitude.Text = "Lat:{0}º".FormatWith(location.Coordinate.Latitude); // courseLabel.Text = $"{location.Course}º"; // speedLabel.Text = $"{location.Speed} meters/s"; // get the distance from here to paris //distanceLabel.Text = $"{location.DistanceFrom(new CLLocation(48.857, 2.351)) / 1000} km"; Client.Common.LBSModel r = null; r = new Common.LBSModel ( _GPSInfoType: string.Empty, _Latitude: location.Coordinate.Latitude.ToString(), _Longitude: location.Coordinate.Longitude.ToString(), _Radius: string.Empty, // location.Radius.ToString(), _Address: string.Empty, // location.AddrStr, _LocationDescribe: string.Empty //location.LocationDescribe ); Client.Common.LBS.OnGetGPSInfo(r); } }
private void handleABC(BMKLocation location, BMKLocationKitIdfa_Structs.BMKLocationNetworkState networkState, NSError error) { if (error != null) { string errorMsg = "[{0}]{1}".FormatWith(error.Code, error.LocalizedDescription); System.Diagnostics.Debug.WriteLine(errorMsg); } Client.Common.LBSModel r = null; //r = new Common.LBSModel //( // _GPSInfoType: tmpGPSInfoType, // _Latitude: location.Location.Coordinate.Latitude.ToString(), // _Longitude: location.Location.Coordinate.Longitude.ToString(), // _Radius: location.Radius.ToString(), // _Address: location.AddrStr, // _LocationDescribe: location.LocationDescribe //); r = new Common.LBSModel ( _GPSInfoType: "", // tmpGPSInfoType, _Latitude: location.Location.Coordinate.Latitude.ToString(), _Longitude: location.Location.Coordinate.Longitude.ToString(), _Radius: "", // location.Radius.ToString(), _Address: "", // location.AddrStr, _LocationDescribe: "" // location.LocationDescribe ); Client.Common.LBS.OnGetGPSInfo(r); }
public override void OnReceiveLocation(BDLocation location) { #region 官方DEMO 组织信息 StringBuilder sb = new StringBuilder(); sb.Append("time : "); sb.Append(location.Time); sb.Append("\nerror code : "); sb.Append(location.LocType); sb.Append("\nlatitude : "); sb.Append(location.Latitude); sb.Append("\nlontitude : "); sb.Append(location.Longitude); sb.Append("\nradius : "); sb.Append(location.Radius); if (location.LocType == BDLocation.TypeGpsLocation) { // GPS定位结果 sb.Append("\nspeed : "); sb.Append(location.Speed); // 单位:公里每小时 sb.Append("\nsatellite : "); sb.Append(location.SatelliteNumber); sb.Append("\nheight : "); sb.Append(location.Altitude); // 单位:米 sb.Append("\ndirection : "); sb.Append(location.Direction); // 单位度 sb.Append("\naddr : "); sb.Append(location.AddrStr); sb.Append("\ndescribe : "); sb.Append("gps定位成功"); } else if (location.LocType == BDLocation.TypeNetWorkLocation) {// 网络定位结果 sb.Append("\naddr : "); sb.Append(location.AddrStr); //运营商信息 sb.Append("\noperationers : "); sb.Append(location.Operators); sb.Append("\ndescribe : "); sb.Append("网络定位成功"); } else if (location.LocType == BDLocation.TypeOffLineLocation) {// 离线定位结果 sb.Append("\ndescribe : "); sb.Append("离线定位成功,离线定位结果也是有效的"); } else if (location.LocType == BDLocation.TypeServerError) { sb.Append("\ndescribe : "); sb.Append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } else if (location.LocType == BDLocation.TypeNetWorkException) { sb.Append("\ndescribe : "); sb.Append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.LocType == BDLocation.TypeCriteriaException) { sb.Append("\ndescribe : "); sb.Append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } sb.Append("\nlocationdescribe : "); sb.Append(location.LocationDescribe);// 位置语义化信息 // System.Collections.Generic.IList list = location.PoiList;// POI数据 if (location.PoiList != null) { sb.Append("\npoilist size = : "); sb.Append(location.PoiList.Count.ToString()); foreach (Poi p in location.PoiList) { sb.Append("\npoi= : "); sb.Append(p.Id + " " + p.Name + " " + p.Rank); } } // System.Diagnostics.Debug.Write(sb.ToString()); // 调试时请开启注释 #endregion 官方DEMO 组织信息 Client.Common.LBSModel r = null; #region 判断是否定位错误 string errorMsg = string.Empty; if (location.LocType == BDLocation.TypeServerError) { errorMsg = "服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"; } else if (location.LocType == BDLocation.TypeNetWorkException) { errorMsg = "网络不同导致定位失败,请检查网络是否通畅"; } else if (location.LocType == BDLocation.TypeCriteriaException) { // errorMsg = "无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"; errorMsg = "无法获取有效定位依据导致定位失败,请查看是否开启定位权限(安卓系统请点击【前往系统-位置信息】按钮);若已启用定位权限,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"; } #endregion // 处理定位错误 if (errorMsg.IsNullOrWhiteSpace() == false) { r = new Common.LBSModel(errorMsg); Client.Common.LBS.OnGetGPSInfo(r); return; } // 4.9E-324 异常情况 if (location.Longitude.ToString().Contains("E-324") || location.Latitude.ToString().Contains("E-324")) { errorMsg = $"可能由于正在定位中导致的经纬度信息异常。lng:4.9E-324; lat:4.9E-324"; r = new Common.LBSModel(errorMsg); Client.Common.LBS.OnGetGPSInfo(r); return; } string tmpGPSInfoType = string.Empty; #region 判断定位方式 if (location.LocType == BDLocation.TypeGpsLocation) { tmpGPSInfoType = "gps定位成功"; } else if (location.LocType == BDLocation.TypeNetWorkLocation) { tmpGPSInfoType = "网络定位成功"; } else if (location.LocType == BDLocation.TypeOffLineLocation) { tmpGPSInfoType = "离线定位成功"; } #endregion // 处理定位正常 r = new Common.LBSModel ( _GPSInfoType: tmpGPSInfoType, _Latitude: location.Latitude.ToString(), _Longitude: location.Longitude.ToString(), _Radius: location.Radius.ToString(), _Address: location.AddrStr, _LocationDescribe: location.LocationDescribe ); Client.Common.LBS.OnGetGPSInfo(r); return; }