void IBDLocationListener.OnReceiveLocation(BDLocation location)
        {
            if (location == null)
            {
                return;
            }
            //Resolver.Resolve<IUserDialogService> ().Alert ("receive dialog");
            MyLocationData locData = new MyLocationData.Builder()
                                     .Accuracy(location.Radius)
                                     // 此处设置开发者获取到的方向信息,顺时针0-360
                                     .Direction(100).Latitude(location.Latitude)
                                     .Longitude(location.Longitude).Build();

            mBaiduMap.SetMyLocationData(locData);
            LatLng cenpt = new LatLng(location.Latitude, location.Longitude);
            //定义地图状态
            MapStatus mMapStatus = new MapStatus.Builder()
                                   .Target(cenpt)
                                   .Zoom(14)
                                   .Build();
            //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
            //
            MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.NewMapStatus(mMapStatus);

            //改变地图状态
            mBaiduMap.SetMapStatus(mMapStatusUpdate);
        }
예제 #2
0
        /// <summary>
        /// 移动位置
        /// </summary>
        /// <param name="coordinate"></param>
        public void AnimateTo(Coordinate coordinate)
        {
            this.mapView.Map.Clear();

            var point = new LatLng(coordinate.Latitude, coordinate.Longitude);

            //Title="雪花啤酒(西安)分公司",Lat=34.364438,Lng=108.941338
            //创建当前位置Marker图标
            BitmapDescriptor bitmap = BitmapDescriptorFactory.FromResource(Resource.Drawable.red_location);
            //构建MarkerOption,用于在地图上添加Marker
            OverlayOptions option = new MarkerOptions()
                                    .InvokePosition(point)
                                    .Anchor(0.5f, 0.5f)
                                    .ScaleX(0.5f)
                                    .ScaleY(0.5f)
                                    .Draggable(true)
                                    .InvokeIcon(bitmap);

            ////在地图上添加Marker,并显示
            this.mapView.Map.AddOverlay(option);


            //使地图移动到当前位置
            MapStatus mMapStatus = new MapStatus.Builder()
                                   .Target(point)
                                   .Zoom(18)
                                   .Build();

            //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
            MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.NewMapStatus(mMapStatus);

            //改变地图状态
            this.mapView.Map.SetMapStatus(mMapStatusUpdate);
        }