com.baidu.mapapi.map.MyLocationConfiguration Java Examples

The following examples show how to use com.baidu.mapapi.map.MyLocationConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteBaiduBusActivity.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void initLocationSDK() {
// 定位初始化
        mLocClient = new LocationClient(this);
        mLocClient.registerLocationListener(this);
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
        option.setCoorType("gcj02");
        option.setOpenGps(true);
        option.setScanSpan(1000);
        option.setIsNeedAltitude(true);
        option.setIsNeedAddress(false);

        mLocClient.setLocOption(option);

        MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
        mBaiduMap.setMyLocationConfiguration(configuration);

        mLocClient.start();

        isFirstLoc = false;

    }
 
Example #2
Source File: RouteBaiduBusActivity.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void initLocationSDK() {
// 定位初始化
        mLocClient = new LocationClient(this);
        mLocClient.registerLocationListener(this);
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
        option.setCoorType("gcj02");
        option.setOpenGps(true);
        option.setScanSpan(1000);
        option.setIsNeedAltitude(true);
        option.setIsNeedAddress(false);

        mLocClient.setLocOption(option);

        MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
        mBaiduMap.setMyLocationConfiguration(configuration);

        mLocClient.start();

        isFirstLoc = false;

    }
 
Example #3
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void initBaiduSdk() {
    // 定位初始化
    mLocClient = new LocationClient(getActivity());
    mLocClient.registerLocationListener(this);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setCoorType("gcj02");
    option.setOpenGps(true);
    option.setScanSpan(1000);
    option.setIsNeedAltitude(true);
    option.setIsNeedAddress(false);

    mLocClient.setLocOption(option);

    MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
    mBaiduMap.setMyLocationConfiguration(configuration);

    mLocClient.start();

}
 
Example #4
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void setModeEDog(boolean isChecked) {

        if (isChecked) {

            if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
                mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.COMPASS, true, null));
                btnLocation.setImageResource(R.drawable.ic_explore_24dp);
            }
            mIsModeEDog = true;
        } else {
            if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode == MyLocationConfiguration.LocationMode.COMPASS) {
                mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null));
                btnLocation.setImageResource(R.drawable.ic_my_location_24dp);
                MapStatus.Builder builder = new MapStatus.Builder().rotate(0).overlook(90);
                mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
            }
            mIsModeEDog = false;

        }
    }
 
Example #5
Source File: MainActivity.java    From VirtualLocation with Apache License 2.0 6 votes vote down vote up
/**
 * iniMap 初始化地图
 */
private void iniMap() {
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(3000);
    mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;

    // 缩放
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(14.0f);
    mBaiduMap.setMapStatus(msu);

    mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker));
    mLocClient.setLocOption(option);
    mLocClient.start();
    initOverlay();

    // 开启线程,一直修改GPS坐标
    LocationUtil.startLocaton();
}
 
Example #6
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void initLocationSDK() {
    // 定位初始化
    mLocClient = new LocationClient(getActivity());
    mLocClient.registerLocationListener(this);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setCoorType("gcj02");
    option.setOpenGps(true);
    option.setScanSpan(1000);
    option.setIsNeedAltitude(true);
    option.setIsNeedAddress(false);

    mLocClient.setLocOption(option);

    MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
    mBaiduMap.setMyLocationConfiguration(configuration);

    mLocClient.start();
    isFirstLoc = false;

}
 
Example #7
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void initBaiduSdk() {
    // 定位初始化
    mLocClient = new LocationClient(getActivity());
    mLocClient.registerLocationListener(this);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setCoorType("gcj02");
    option.setOpenGps(true);
    option.setScanSpan(1000);
    option.setIsNeedAltitude(true);
    option.setIsNeedAddress(false);

    mLocClient.setLocOption(option);

    MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
    mBaiduMap.setMyLocationConfiguration(configuration);

    mLocClient.start();

}
 
Example #8
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void setModeEDog(boolean isChecked) {

        if (isChecked) {

            if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
                mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.COMPASS, true, null));
                btnLocation.setImageResource(R.drawable.ic_explore_24dp);
            }
            mIsModeEDog = true;
        } else {
            if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode == MyLocationConfiguration.LocationMode.COMPASS) {
                mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null));
                btnLocation.setImageResource(R.drawable.ic_my_location_24dp);
                MapStatus.Builder builder = new MapStatus.Builder().rotate(0).overlook(90);
                mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
            }
            mIsModeEDog = false;

        }
    }
 
Example #9
Source File: MapFragment.java    From MapForTour with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_map, container, false);
    // Inflate the layout for this fragment
    switchLocation = (Switch) view.findViewById(R.id.switchLocation);
    switchLBSTrace = (Switch) view.findViewById(R.id.switchLBSTrace);
    switchLocation.setOnCheckedChangeListener(this);
    switchLBSTrace.setOnCheckedChangeListener(this);
    mMapView = (TextureMapView) view.findViewById(R.id.bmapView);
    baiduMap = mMapView.getMap();
    baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null));
    application.setMaxZoomLevel(baiduMap.getMaxZoomLevel());
    // 开启定位图层
    baiduMap.setMyLocationEnabled(true);
    baiduMap.setOnMarkerClickListener(this);
    //再次进入地图fragment时界面刷新
    if (application.latLng != null) {
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2);
        baiduMap.animateMapStatus(u);//动画移动摄像头
        if (radarNearbyInfoList != null) {
            refreshMapUI();
        }
    }
    return view;
}
 
Example #10
Source File: MapFragment.java    From MapForTour with MIT License 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.switchLBSTrace:
            if (isChecked) {
                polylineMyTrace = new PolylineOptions();
                refreshMapUI();
                mlistener.toolbarOperateCloseTrackOrOpenColor(true);
            } else {
                mlistener.toolbarOperateCloseTrackOrOpenColor(false);
            }
            break;
        case R.id.switchLocation:
            if (isChecked) {
                baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, false, null));
                baiduMap.animateMapStatus(MapStatusUpdateFactory.zoomTo(baiduMap.getMaxZoomLevel() - 2));
            } else
                baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null));
            break;
    }
}
 
Example #11
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void initLocationSDK() {
    // 定位初始化
    mLocClient = new LocationClient(getActivity());
    mLocClient.registerLocationListener(this);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setCoorType("gcj02");
    option.setOpenGps(true);
    option.setScanSpan(1000);
    option.setIsNeedAltitude(true);
    option.setIsNeedAddress(false);

    mLocClient.setLocOption(option);

    MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
    mBaiduMap.setMyLocationConfiguration(configuration);

    mLocClient.start();
    isFirstLoc = false;

}
 
Example #12
Source File: MapActivity.java    From foodie-app with Apache License 2.0 5 votes vote down vote up
private void startLocationOverlap() {
    //开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    //构造定位数据
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(mLocation.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(mLocation.getLatitude())
            .longitude(mLocation.getLongitude()).build();
    // 设置定位数据
    mBaiduMap.setMyLocationData(locData);
    // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
    //构建Marker图标
    BitmapDescriptor bitmap = BitmapDescriptorFactory
            .fromResource(R.drawable.my_location);
    //bitmap.
    MyLocationConfiguration config = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, bitmap);
    mBaiduMap.setMyLocationConfigeration(config);
    //中心点为我的位置
    LatLng cenpt = new LatLng(locData.latitude, locData.longitude);
    //定义地图状态
    MapStatus mMapStatus = new MapStatus.Builder()
            .target(cenpt)
            .zoom(mCurrentLevel)
            .build();
    //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
    //改变地图状态
    mBaiduMap.setMapStatus(mMapStatusUpdate);
    // 当不需要定位图层时关闭定位图层
    //mBaiduMap.setMyLocationEnabled(false);
}
 
Example #13
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void setDrivingOverlay(DrivingRouteLine line) {
    mBaiduMap.clear();
    DrivingRouteOverlay overlay = new DrivingRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mMapView && null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #14
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private void initMap() {
    baiduMap = mBaiduMap.getMap();

    baiduMap.setMyLocationEnabled(true);

    mlocationClient = new LocationClient(getApplicationContext());
    mlocationClient.registerLocationListener(new MylocationListener());
    //  mBaiduMap.showScaleControl(false);// 隐藏比例尺控件
    mBaiduMap.showZoomControls(false);//隐藏缩放按钮

    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true); // 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(5000);//设置onReceiveLocation()获取位置的频率
    option.setIsNeedAddress(true);//如想获得具体位置就需要设置为true
    mlocationClient.setLocOption(option);
    mlocationClient.start();
    mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING;
    baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
            mCurrentMode, true, null));
    myOrientationListener = new MyOrientationListener(this);
    //通过接口回调来实现实时方向的改变
    myOrientationListener.setOnOrientationListener(new MyOrientationListener.OnOrientationListener() {
        @Override
        public void onOrientationChanged(float x) {
            mCurrentX = x;
        }
    });
    myOrientationListener.start();
    mSearch = RoutePlanSearch.newInstance();
    mSearch.setOnGetRoutePlanResultListener(this);
    initMarkerClickEvent();
}
 
Example #15
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private void beginService() {
    if (!Utils.isGpsOPen(this)) {
        Utils.showDialog(this);
        return;
    }
    isNeedCurrentlocation = true;
    mScan_qrcode.setVisibility(View.GONE);
    mTvLocationInfo.setVisibility(View.GONE);
    mBikeInfoBoard.setVisibility(View.VISIBLE);
    mLoBikeInfo.setVisibility(View.VISIBLE);
    mBikeOrderBoard.setVisibility(View.GONE);
    mBtLoginOrorder.setText("结束骑行");
    mBtLoginOrorder.setVisibility(View.VISIBLE);
    mMinute1.setText("骑行时长");
    mTvDistance1.setText("骑行距离");
    mTvPrices1.setText("费用计算");
    mRefreshAll.setVisibility(View.GONE);
    countDownTimer.cancel();

    if (routeOverlay != null)
        routeOverlay.removeFromMap();
    mBaiduMap.showZoomControls(false);
    baiduMap.clear();
    if (isServiceLive)
        mlocationClient.requestLocation();
    Intent intent = new Intent(this, RouteService.class);
    startService(intent);
    MyLocationConfiguration configuration
            = new MyLocationConfiguration(locationMode, true, mIconLocation);
    //设置定位图层配置信息,只有先允许定位图层后设置定位图层配置信息才会生
}
 
Example #16
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
    if (null != location && location.getLocType() != BDLocation.TypeServerError) {
        //

        MyLocationData data = new MyLocationData.Builder()//
                // .direction(mCurrentX)//
                .accuracy(location.getRadius())//
                .latitude(location.getLatitude())//
                .longitude(location.getLongitude())//
                .build();
        mBaiduMap.setMyLocationData(data);
        // 设置自定义图标
        MyLocationConfiguration config = new MyLocationConfiguration(
                MyLocationConfiguration.LocationMode.NORMAL, true, null);
        mBaiduMap.setMyLocationConfigeration(config);
        mAddress = location.getAddrStr();
        mName = location.getStreet();
        mCity = location.getCity();

        LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
        mLoactionLatLng = currentLatLng;
        // 是否第一次定位
        if (isFirstLoc) {
            isFirstLoc = false;
            // 实现动画跳转
            MapStatusUpdate u = MapStatusUpdateFactory
                    .newLatLng(currentLatLng);
            mBaiduMap.animateMapStatus(u);
            mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption())
                    .location(currentLatLng));
            return;
        }
    }

}
 
Example #17
Source File: MapFragment.java    From MapForTour with MIT License 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();
    //在activity执行onPause时执行mMapView. onPause (),实现地图生命周期管理
    baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null));
    mMapView.onPause();
}
 
Example #18
Source File: RouteBaiduBusActivity.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void setTransitOverlay(TransitRouteLine line) {
    mBaiduMap.clear();
    TransitRouteOverlay overlay = new TransitRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mBaiduMap.getLocationConfigeration() && mBaiduMap.getLocationConfigeration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #19
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
public void initLocationSdk() {
    // 定位初始化
    mLocClient = new LocationClient(getActivity());
    mLocClient.registerLocationListener(this);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setCoorType("gcj02");
    option.setOpenGps(true);
    option.setScanSpan(1000);
    option.setIsNeedAltitude(true);
    option.setIsNeedAddress(false);

    mLocClient.setLocOption(option);

    MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
    mBaiduMap.setMyLocationConfiguration(configuration);

    mLocClient.start();

    try {
        LocationManager locManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
        if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            onMessage(getResources().getString(R.string.gps_enabled_false));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }


}
 
Example #20
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void setWalkingOverlay(WalkingRouteLine line) {
    mBaiduMap.clear();
    WalkingRouteOverlay overlay = new WalkingRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mMapView && null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #21
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void setBikeOverlay(BikingRouteLine line) {
    mBaiduMap.clear();
    BikingRouteOverlay overlay = new BikingRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mMapView && null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #22
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void setDrivingOverlay(DrivingRouteLine line) {
    mBaiduMap.clear();
    DrivingRouteOverlay overlay = new DrivingRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mMapView && null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #23
Source File: RouteBaiduBusActivity.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void setTransitOverlay(TransitRouteLine line) {
    mBaiduMap.clear();
    TransitRouteOverlay overlay = new TransitRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mBaiduMap.getLocationConfigeration() && mBaiduMap.getLocationConfigeration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #24
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
public void initLocationSdk() {
    // 定位初始化
    mLocClient = new LocationClient(getActivity());
    mLocClient.registerLocationListener(this);
    LocationClientOption option = new LocationClientOption();
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    option.setCoorType("gcj02");
    option.setOpenGps(true);
    option.setScanSpan(1000);
    option.setIsNeedAltitude(true);
    option.setIsNeedAddress(false);

    mLocClient.setLocOption(option);

    MyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null);
    mBaiduMap.setMyLocationConfiguration(configuration);

    mLocClient.start();

    try {
        LocationManager locManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
        if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            onMessage(getResources().getString(R.string.gps_enabled_false));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }


}
 
Example #25
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void setWalkingOverlay(WalkingRouteLine line) {
    mBaiduMap.clear();
    WalkingRouteOverlay overlay = new WalkingRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mMapView && null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #26
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void setBikeOverlay(BikingRouteLine line) {
    mBaiduMap.clear();
    BikingRouteOverlay overlay = new BikingRouteOverlay(mBaiduMap);
    mBaiduMap.setOnMarkerClickListener(overlay);
    overlay.setData(line);
    overlay.addToMap();
    if (null != mMapView && null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) {
        overlay.zoomToSpan();
    }

}
 
Example #27
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@OnClick({R.id.ancp_back_bt, R.id.ancp_map_locate_bt, R.id.ancp_zoom_in_bt, R.id.ancp_zoom_out_bt,
        R.id.ancp_poi_detial_pre_bt, R.id.ancp_poi_detial_next_bt, R.id.ancp_map_its_bt})
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.ancp_back_bt:
            onBackPressed();
            break;
        case R.id.ancp_map_locate_bt:
            /* 封装定位信息 */
            BDLocation location = new BDLocation();
            location.setLatitude(address.getLatitude());
            location.setLongitude(address.getLongitude());
            location.setRadius(address.getRadius());
            location.setSpeed(address.getSpeed());
            location.setSatelliteNumber(address.getSatelliteNumber());
            location = LocationClient.getBDLocationInCoorType(location, BDLocation.BDLOCATION_GCJ02_TO_BD09LL);
            /* 开启定位图层 */
            baiduMap.setMyLocationEnabled(true);
            // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
            baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, true, null));
            /* 构造定位数据并设置 */
            baiduMap.setMyLocationData(new MyLocationData.Builder().latitude(location.getLatitude())
                    .longitude(location.getLongitude())
                    .accuracy(location.getRadius())
                    .direction(location.getDirection())
                    .satellitesNum(location.getSatelliteNumber())
                    .speed(location.getSpeed())
                    .build());
            break;
        case R.id.ancp_zoom_in_bt:
            baiduMap.setMapStatus(MapStatusUpdateFactory.zoomIn());
            break;
        case R.id.ancp_zoom_out_bt:
            baiduMap.setMapStatus(MapStatusUpdateFactory.zoomOut());
            break;
        case R.id.ancp_poi_detial_pre_bt:
            if (mAncpPoiDetailPager.getCurrentItem() > 0 && mAncpPoiDetailPager.getCurrentItem() < list.size()) {
                showPoiDetail(mAncpPoiDetailPager.getCurrentItem() - 1);
            }
            break;
        case R.id.ancp_poi_detial_next_bt:
            if (mAncpPoiDetailPager.getCurrentItem() >= 0 && mAncpPoiDetailPager.getCurrentItem() < list.size() - 1) {
                showPoiDetail(mAncpPoiDetailPager.getCurrentItem() + 1);
            }
            break;
        case R.id.ancp_map_its_bt:
            if (baiduMap.isTrafficEnabled()) {
                baiduMap.setTrafficEnabled(false);
                ((ImageButton) view).setImageResource(R.drawable.bnav_common_ic_map_its_off);
            } else {
                baiduMap.setTrafficEnabled(true);
                ((ImageButton) view).setImageResource(R.drawable.bnav_common_ic_map_its_on);
            }
            break;
    }
}
 
Example #28
Source File: MapFragment.java    From apollo-DuerOS with Apache License 2.0 4 votes vote down vote up
private void initMap() {
    // set button which can change large or small
    mMapView.setMapCustomEnable(true);
    View child = mMapView.getChildAt(1);
    // remove logo
    if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) {
        child.setVisibility(View.INVISIBLE);
        // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app));
    }
    mMapView.showZoomControls(false);
    mMapView.showScaleControl(false);

    mBaiduMap = mMapView.getMap();
    // enable location layer
    mBaiduMap.setMyLocationEnabled(true);
    // unable traffic picture
    mBaiduMap.setTrafficEnabled(false);
    mBaiduMap.setBaiduHeatMapEnabled(false);
    mBaiduMap.setIndoorEnable(false);
    mBaiduMap.setBuildingsEnabled(false);

    mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING;
    mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker));
    // set custom icon、marker
    mCurrentMarker = BitmapDescriptorFactory
            .fromResource(R.drawable.car_point);
    mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(
            mCurrentMode, true, mCurrentMarker,
            accuracyCircleFillColor, accuracyCircleStrokeColor));

    mCurrentLat = MapSdkWrapper.getLatitudeBd09ll();
    mCurrentLon = MapSdkWrapper.getLongitudeBd09ll();
    // get direction info,clockwise 0-360
    locData = new MyLocationData.Builder().accuracy((float) mCurrentAccracy)
            .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build();
    mBaiduMap.setMyLocationData(locData);
    LatLng ll = new LatLng(mCurrentLat, mCurrentLon);
    MapStatus.Builder builder = new MapStatus.Builder();
    builder.target(ll);
    // you can customize the size. level=19,the default scale is 14--100 meter
    MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5);
    mBaiduMap.animateMapStatus(u);
    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback);
    LogUtil.i(TAG, "Map is init");
}
 
Example #29
Source File: MapFragment.java    From apollo-DuerOS with Apache License 2.0 4 votes vote down vote up
private void initMap() {
    // Set the enlargement and reduction button
    mMapView.setMapCustomEnable(true);
    View child = mMapView.getChildAt(1);
    // delete logo
    if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) {
        child.setVisibility(View.INVISIBLE);
        // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app));
    }
    mMapView.showZoomControls(false);
    mMapView.showScaleControl(false);

    mBaiduMap = mMapView.getMap();
    // Open the location layer
    mBaiduMap.setMyLocationEnabled(true);
    // Close the traffic map
    mBaiduMap.setTrafficEnabled(false);
    mBaiduMap.setBaiduHeatMapEnabled(false);
    mBaiduMap.setIndoorEnable(false);
    mBaiduMap.setBuildingsEnabled(false);

    mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING;
    mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker));
    // set custom logo
    // Modify it to custom marker
    mCurrentMarker = BitmapDescriptorFactory
            .fromResource(R.drawable.car_point);
    mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(
            mCurrentMode, true, mCurrentMarker,
            accuracyCircleFillColor, accuracyCircleStrokeColor));

    mCurrentLat = MapSdkWrapper.getLatitudeBd09ll();
    mCurrentLon = MapSdkWrapper.getLongitudeBd09ll();
    // set the direction information that developers get,clockwise:0-360
    locData = new MyLocationData.Builder().accuracy(mCurrentAccracy)
            .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build();
    mBaiduMap.setMyLocationData(locData);
    LatLng ll = new LatLng(mCurrentLat, mCurrentLon);
    MapStatus.Builder builder = new MapStatus.Builder();
    builder.target(ll);
    MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5);
    mBaiduMap.animateMapStatus(u);
    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback);
    LogUtil.i(TAG, "Map is init");
}
 
Example #30
Source File: RouteService.java    From Mobike with Apache License 2.0 4 votes vote down vote up
private void initLocation() {
        mIconLocation = BitmapDescriptorFactory
                .fromResource(R.mipmap.location_marker);
        locationMode = MyLocationConfiguration.LocationMode.NORMAL;

        //定位服务的客户端。宿主程序在客户端声明此类,并调用,目前只支持在主线程中启动
        mlocationClient = new LocationClient(this);
        mlistener = new MylocationListener();
//        initMarkerClickEvent();
        //注册监听器
        mlocationClient.registerLocationListener(mlistener);
        //配置定位SDK各配置参数,比如定位模式、定位时间间隔、坐标系类型等
        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);

        //初始化图标,BitmapDescriptorFactory是bitmap 描述信息工厂类.
        mIconLocation = BitmapDescriptorFactory
                .fromResource(R.mipmap.location_marker);

        myOrientationListener = new MyOrientationListener(this);
        //通过接口回调来实现实时方向的改变
        myOrientationListener.setOnOrientationListener(new MyOrientationListener.OnOrientationListener() {
            @Override
            public void onOrientationChanged(float x) {
            }
        });
//        mSearch = RoutePlanSearch.newInstance();
//        mSearch.setOnGetRoutePlanResultListener(this);
//        //开启定位
//        mBaiduMap.setMyLocationEnabled(true);
        if (!mlocationClient.isStarted()) {
            mlocationClient.start();
        }
        myOrientationListener.start();
    }