public void OnReceiveLocation(BDLocation location)
        {
            if (location == null)
            {
                return;
            }
            Log.Info(Tag, "BDLocationListener OnReceiveLocation");

            int locType = location.LocType;

            if (locType != 161)
            {
                Toast.MakeText(this, " 定位失败!", 0).Show();
            }
            CurrentData.Latitude = location.Latitude;
            CurrentData.Longitude = location.Longitude;
            CurrentData.Address = location.AddrStr;
        }
			public void OnReceiveLocation (BDLocation location)
			{
				//Receive Location 
				StringBuilder sb = new StringBuilder(256);
				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);
				sb.Append ("\n"+location.Country+" "+location.City+" "+location.Street+" "+location.AddrStr+" \n");
				if (location.LocType== BDLocation.TypeGpsLocation){
					sb.Append("\nspeed : ");
					sb.Append(location.Speed);
					sb.Append("\nsatellite : ");
					sb.Append(location.SatelliteNumber);
					sb.Append("\ndirection : ");
					sb.Append("\naddr : ");
					sb.Append(location.AddrStr);
					sb.Append(location.Direction);
				} else if (location.LocType == BDLocation.TypeNetWorkLocation){
					sb.Append("\naddr : ");
					sb.Append(location.AddrStr);
					//运营商信息
					sb.Append("\noperationers : ");
					sb.Append(location.Operators);
				}
				//LogMsg(sb.ToString());
				mHandlder.Post(()=>{
					//textView.Text = sb.ToString ();
					Toast.MakeText(mContext,sb.ToString(),ToastLength.Long).Show();
				});

				Log.Info("BaiduLocationApiDem", sb.ToString());
			}
示例#3
0
 public void OnReceiveLocation(BDLocation location)
 {
     // map view 销毁后不在处理新接收的位置
     if (location == null || _Activity.mMapView == null)
         return;
     MyLocationData locData = new MyLocationData.Builder()
             .Accuracy(location.Radius)
         // 此处设置开发者获取到的方向信息,顺时针0-360
             .Direction(100).Latitude(location.Latitude)
             .Longitude(location.Longitude).Build();
     _Activity.mBaiduMap.SetMyLocationData(locData);
     if (_Activity.isFirstLoc)
     {
         _Activity.isFirstLoc = false;
         LatLng ll = new LatLng(location.Latitude, location.Longitude);
         MapStatusUpdate u = MapStatusUpdateFactory.NewLatLng(ll);
         _Activity.mBaiduMap.AnimateMapStatus(u);
     }
 }
        //private double longitude;
        //private double latitude;
        public void OnReceiveLocation(BDLocation location)
        {
            if (location == null)
            {
                return;
            }
            Log.Info(Tag, "BDLocationListener OnReceiveLocation");

            int locType = location.LocType;
            //longitude = location.Longitude;
            //latitude = location.Latitude;
            CurrentData.Latitude = location.Latitude;
            CurrentData.Longitude = location.Longitude;
            //Resource.String.
            //Receive Location

            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);
            switch (location.LocType)
            {
                case 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定位成功");
                    break;
                case BDLocation.TypeNetWorkLocation:
                    // 网络定位结果
                    sb.Append("\naddr : ");
                    sb.Append(location.AddrStr);
                    //运营商信息
                    sb.Append("\noperationers : ");
                    sb.Append(location.Operators);
                    sb.Append("\ndescribe : ");
                    sb.Append("网络定位成功");
                    break;
                case BDLocation.TypeOffLineLocation:
                    // 离线定位结果
                    sb.Append("\ndescribe : ");
                    sb.Append("离线定位成功,离线定位结果也是有效的");
                    break;
                case BDLocation.TypeServerError:
                    sb.Append("\ndescribe : ");
                    sb.Append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因");
                    break;
                case BDLocation.TypeNetWorkException:
                    sb.Append("\ndescribe : ");
                    sb.Append("网络不同导致定位失败,请检查网络是否通畅");
                    break;
                case BDLocation.TypeCriteriaException:
                    sb.Append("\ndescribe : ");
                    sb.Append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
                    break;
            }

            // LogMsg(sb.ToString());
            Log.Info(Tag, sb.ToString());
            //mLocationClient.setEnableGpsRealTimeTransfer(true);
        }
 public void OnReceivePoi(BDLocation poiLocation)
 {
     if (poiLocation == null)
     {
         return;
     }
 }
            public void OnReceiveLocation(BDLocation location)
            {
                if (location == null)
                    return;

                locationOverlayDemo.locData.Latitude = location.Latitude;
                locationOverlayDemo.locData.Longitude = location.Longitude;
                //如果不显示定位精度圈,将accuracy赋值为0即可
                locationOverlayDemo.locData.Accuracy = location.Radius;
                // 此处可以设置 locData的方向信息, 如果定位 SDK 未返回方向信息,用户可以自己实现罗盘功能添加方向信息。
                locationOverlayDemo.locData.Direction = location.Derect;
                //更新定位数据
                locationOverlayDemo.myLocationOverlay.SetData(locationOverlayDemo.locData);
                //更新图层数据执行刷新后生效
                locationOverlayDemo.mMapView.Refresh();
                //是手动触发请求或首次定位时,移动到定位点
                if (locationOverlayDemo.isRequest || locationOverlayDemo.isFirstLoc)
                {
                    //移动地图到定位点
                    Log.Debug("LocationOverlay", "receive location, animate to it");
                    locationOverlayDemo.mMapController.AnimateTo(new GeoPoint((int)(locationOverlayDemo.locData.Latitude * 1e6), (int)(locationOverlayDemo.locData.Longitude * 1e6)));
                    locationOverlayDemo.isRequest = false;
                    locationOverlayDemo.myLocationOverlay.SetLocationMode(Com.Baidu.Mapapi.Map.MyLocationOverlay.LocationMode.Following);
                    locationOverlayDemo.requestLocButton.Text = "跟随";
                    locationOverlayDemo.mCurBtnType = E_BUTTON_TYPE.FOLLOW;
                }
                //首次定位完成
                locationOverlayDemo.isFirstLoc = false;
            }
示例#7
0
 public void OnReceivePoi(BDLocation poiLocation)
 {
 }
示例#8
0
 public void OnReceiveLocation(BDLocation location)
 {
     // map view ���ٺ��ڴ����½��յ�λ��
     if (location == null || locationOverlayDemo.mMapView == null)
         return;
     MyLocationData locData = new MyLocationData.Builder()
             .Accuracy(location.Radius)
         // �˴����ÿ����߻�ȡ���ķ�����Ϣ��˳ʱ��0-360
             .Direction(100).Latitude(location.Latitude)
             .Longitude(location.Longitude).Build();
     locationOverlayDemo.mBaiduMap.SetMyLocationData(locData);
     if (locationOverlayDemo.isFirstLoc)
     {
         locationOverlayDemo.isFirstLoc = false;
         LatLng ll = new LatLng(location.Latitude,
                 location.Longitude);
         MapStatusUpdate u = MapStatusUpdateFactory.NewLatLng(ll);
         locationOverlayDemo.mBaiduMap.AnimateMapStatus(u);
     }
 }