public RotationGestureOverlay(Context context, MapView mapView)
     : base(context)
 {
     OptionsMenuEnabled = true;
     _mMapView = mapView;
     _mRotationDetector = new RotationGestureDetector(this);
 }
        public bool OnOptionsItemSelected(IMenuItem menuItem, int menuIdOffset, MapView mapView)
        {
            if (menuItem.ItemId == MenuEnabled + menuIdOffset)
            {
                if (Enabled)
                {
                    _mMapView.MapOrientation = 0;
                    Enabled = false;
                }
                else
                {
                    Enabled = true;
                    return true;
                }
            }
            else if (menuItem.ItemId == MenuRotateCcw + menuIdOffset)
            {
                _mMapView.MapOrientation -= 10;
            }
            else if (menuItem.ItemId == MenuRotateCw + menuIdOffset)
            {
                _mMapView.MapOrientation += 10;
            }

            return false;
        }
 public override bool OnTouchEvent(MotionEvent motionEvent, MapView mapView)
 {
     if (Enabled)
     {
         _mRotationDetector.OnTouch(motionEvent);
     }
     return base.OnTouchEvent(motionEvent, mapView);
 }
 public bool OnCreateOptionsMenu(IMenu menu, int menuIdOffset, MapView mapView)
 {
     menu.Add(0, MenuEnabled + menuIdOffset, Menu.None, "Enable rotation").SetIcon(
         Android.Resource.Drawable.IcMenuInfoDetails);
     if (ShowRotateMenuItems)
     {
         menu.Add(0, MenuRotateCcw + menuIdOffset, Menu.None,
             "Rotate maps counter clockwise").SetIcon(Android.Resource.Drawable.IcMenuRotate);
         menu.Add(0, MenuRotateCw + menuIdOffset, Menu.None, "Rotate maps clockwise")
             .SetIcon(Android.Resource.Drawable.IcMenuRotate);
     }
     return true;
 }
        private void InitMapView()
        {
            var mapView = FindViewById<MapView>(R.Id.mapView);  // mapPath

            ITileSource tileSource = TileSourceFactory.Mapnik;

            mapView.SetTileSource(tileSource);
            mapView.TilesScaledToDpi = true;
            mapView.SetMultiTouchControls(true);
            mapView.Zoom += mapView_Zoom;
            mapView.Scroll += mapView_Scroll;

            //---------------���õ�ͼ��ת-------------------
            //_mRotationGestureOverlay = new RotationGestureOverlay(this, mapView);
            //_mRotationGestureOverlay.Enabled = true;
            //mapView.Overlays.Add(_mRotationGestureOverlay);

            mapController = mapView.Controller;
            mapController.SetZoom(15);
            GeoPoint startPoint = new GeoPoint(30.538079, 114.4159972);
            mapController.SetCenter(startPoint);

            DefaultResourceProxyImpl resourceProxy = new DefaultResourceProxyImpl(this);
            myLocationoverlay = new MyLocationNewOverlay(this, new GpsMyLocationProvider(this), mapView);
            myLocationoverlay.EnableMyLocation(); // not on by default
            myLocationoverlay.RunOnFirstFix(this);
            mapView.Overlays.Add(myLocationoverlay);
            _mapView = mapView;
        }
Esempio n. 6
0
 public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
 {
     _resourceProxy = new ResourceProxyImpl(inflater.Context.ApplicationContext);
     _mapView = new MapView(inflater.Context, 256, _resourceProxy);
     return _mapView;
 }
 public bool OnPrepareOptionsMenu(IMenu menu, int menuIdOffset, MapView mapView)
 {
     menu.FindItem(MenuEnabled + menuIdOffset).SetTitle(
         Enabled ? "Disable rotation" : "Enable rotation");
     return false;
 }
 public override void Draw(Canvas canvas, MapView mapView, bool shadow)
 {
     // No drawing necessary
 }
            public override void Draw(Canvas c, MapView osmv, bool shadow)
            {
                if (shadow)
                    return;

                var proj = osmv.Projection;

                proj.ToPixels(_mTopLeft, _mTopLeftPoint);
                proj.ToPixels(_mBottomRight, _mBottomRightPoint);

                var area = new Rect(_mTopLeftPoint.X, _mTopLeftPoint.Y, _mBottomRightPoint.X, _mBottomRightPoint.Y);
                c.DrawRect(area, Paint);
            }
 public AreaSelectTool(MapView mapView, Context context)
     : base(context)
 {
     _mapView = mapView;
     this.context = context;
 }
        public override bool OnTouchEvent(MotionEvent e, MapView mapView)
        {
            float x = e.GetX();
            float y = e.GetY();
            int operationType = GetOperationType(e);
            switch (operationType)
            {
                case OPER_TRANSLATE:
                    Translate(x, y);

                    break;
                case OPER_SCALE:
                    Scale(e);
                    break;
                case OPER_ROTATE:
                    //Rotate(e);
                    break;
                default:
                    _mapView.Invalidate();
                    break;
            }

            lastPoint[0] = e.GetX();//�뿪��ĻX����
            lastPoint[1] = e.GetY();//�뿪��ĻY����
            if (isMultipleFingers)
            {
                return false;//�õ�ͼ�ƶ�
            }
            else
            {
                if (isOnSelectTool)
                    return true;//��ֹ��ͼ�ƶ�
                else
                    return false;//�õ�ͼ�ƶ�
            }
        }
 /// <summary>
 /// ��ʼ����
 /// </summary>
 /// <param name="c"></param>
 /// <param name="osmv"></param>
 /// <param name="shadow"></param>
 public override void Draw(Canvas c, MapView osmv, bool shadow)
 {
     if (_pointList != null)
     {
         DrawBackground(c);//���Ʊ���,�Ա���Ծ��ε�ӳ��
         // c.DrawBitmap(mainBmp, matrix, paint);//������ͼƬ
         DrawFrame(c);//���Ʊ߿�,�Ա���Ե��ӳ��
         DrawControlPoints(c);//���ƿ��Ƶ�ͼƬ
         DrawFlyingPath(c);
     }
 }