private void initMap() { mlocationClient = new LocationClient(this); // mlistener = new MylocationListener(); // mlocationClient.registerLocationListener(mlistener); LocationClientOption mOption = new LocationClientOption(); //设置坐标类型 mOption.setCoorType("bd09ll"); //设置是否需要地址信息,默认为无地址 mOption.setIsNeedAddress(true); //设置是否打开gps进行定位 mOption.setOpenGps(true); //设置扫描间隔,单位是毫秒 当<1000(1s)时,定时定位无效 int span = 10000; mOption.setScanSpan(span); //设置 LocationClientOption mlocationClient.setLocOption(mOption); if (!mlocationClient.isStarted()) { mlocationClient.start(); } UiSettings settings = routeBaiduMap.getUiSettings(); settings.setScrollGesturesEnabled(true); }
private void setupMapUI(BaiduMap map) { map.setMyLocationEnabled(true); map.setMyLocationConfigeration(new MyLocationConfiguration(LocationMode.NORMAL, true, null)); mBDLocClient = new LocationClient(getActivity().getApplicationContext()); mBDLocClient.registerLocationListener(mBDLocListener); // Hide the zoom control map.setViewPadding(0, 0, 0, baseBottomPadding); UiSettings mUiSettings = map.getUiSettings(); mUiSettings.setCompassEnabled(false); mUiSettings.setOverlookingGesturesEnabled(false); mUiSettings.setZoomGesturesEnabled(true); mUiSettings.setRotateGesturesEnabled(mAppPrefs.isMapRotationEnabled()); }
/** * init mapview */ public void initMap() { mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); // remove map logo mMapView.removeViewAt(1); int childCount = mMapView.getChildCount(); View zoom = null; for (int i = 0; i < childCount; i++) { View child = mMapView.getChildAt(i); if (child instanceof ZoomControls) { zoom = child; break; } } zoom.setVisibility(View.GONE); mBaiduMap = mMapView.getMap(); UiSettings mUiSettings = mBaiduMap.getUiSettings(); mUiSettings.setCompassEnabled(false); mBaiduMap.setMyLocationEnabled(true); mLocClient = new LocationClient(this); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); option.setOpenGps(true); option.setCoorType("bd09ll"); option.setScanSpan(1000); option.setIsNeedAddress(true); mLocClient.setLocOption(option); mLocClient.start(); }