コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            /**
             * 由于MapView在setContentView()中初始化,所以它需要在BMapManager初始化之后
             */
            SetContentView(Resource.Layout.activity_layers);

            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            /**
             * 获取地图控制器
             */
            mMapController = mMapView.Controller;
            /**
             *  设置地图是否响应点击事件  .
             */
            mMapController.EnableClick(true);
            /**
             * 设置地图缩放级别
             */
            mMapController.SetZoom(12);
            /**
             * 显示内置缩放控件
             */
            mMapView.SetBuiltInZoomControls(true);

            /**
             * 将地图移动至天安门
             * 使用百度经纬度坐标,可以通过http://api.map.baidu.com/lbsapi/getpoint/index.html查询地理坐标
             * 如果需要在百度地图上显示使用其他坐标系统的位置,请发邮件至[email protected]申请坐标转换接口
             */
            double cLat = 39.945;
            double cLon = 116.404;
            GeoPoint p = new GeoPoint((int)(cLat * 1E6), (int)(cLon * 1E6));
            mMapController.SetCenter(p);
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManageResource.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            /**
              * 由于MapView在setContentView()中初始化,所以它需要在BMapManager初始化之后
              */
            SetContentView(Resource.Layout.activity_overlay);
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mClearBtn = FindViewById<Button>(Resource.Id.clear);
            mResetBtn = FindViewById<Button>(Resource.Id.reset);
            /**
             * 获取地图控制器
             */
            mMapController = mMapView.Controller;
            /**
             *  设置地图是否响应点击事件  .
             */
            mMapController.EnableClick(true);
            /**
             * 设置地图缩放级别
             */
            mMapController.SetZoom(14);
            /**
             * 显示内置缩放控件
             */
            mMapView.SetBuiltInZoomControls(true);

            InitOverlay();

            /**
             * 设定地图中心点
             */
            GeoPoint p = new GeoPoint((int)(39.933859 * 1E6), (int)(116.400191 * 1E6));
            mMapController.SetCenter(p);
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.routeplan);
            ICharSequence titleLable = new String("路线规划功能");
            Title = titleLable.ToString();
            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.SetBuiltInZoomControls(false);
            mMapView.Controller.SetZoom(12);
            mMapView.Controller.EnableClick(true);

            //初始化按键
            mBtnDrive = FindViewById<Button>(Resource.Id.drive);
            mBtnTransit = FindViewById<Button>(Resource.Id.transit);
            mBtnWalk = FindViewById<Button>(Resource.Id.walk);
            mBtnPre = FindViewById<Button>(Resource.Id.pre);
            mBtnNext = FindViewById<Button>(Resource.Id.next);
            mBtnCusRoute = FindViewById<Button>(Resource.Id.custombutton);
            mBtnCusIcon = FindViewById<Button>(Resource.Id.customicon);
            mBtnPre.Visibility = ViewStates.Invisible;
            mBtnNext.Visibility = ViewStates.Invisible;

            //按键点击事件
            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);
            Android.Views.View.IOnClickListener nodeClickListener = new NodeClickListenerImpl(this);
            Android.Views.View.IOnClickListener customClickListener = new CustomClickListenerImpl(this);
            Android.Views.View.IOnClickListener changeRouteIconListener = new ChangeRouteIconListenerImpl(this);

            mBtnDrive.SetOnClickListener(clickListener);
            mBtnTransit.SetOnClickListener(clickListener);
            mBtnWalk.SetOnClickListener(clickListener);
            mBtnPre.SetOnClickListener(nodeClickListener);
            mBtnNext.SetOnClickListener(nodeClickListener);
            mBtnCusRoute.SetOnClickListener(customClickListener);
            mBtnCusIcon.SetOnClickListener(changeRouteIconListener);
            //创建 弹出泡泡图层
            CreatePaopao();

            //地图点击事件处理
            mMapView.RegMapTouchListner(new IMKMapTouchListenerImpl(this));
            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new IMKSearchListenerImpl(this));
        }