Java Code Examples for com.baidu.mapapi.map.MapStatusUpdateFactory#zoomTo()

The following examples show how to use com.baidu.mapapi.map.MapStatusUpdateFactory#zoomTo() . 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: 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 2
Source File: MapFragment.java    From apollo-DuerOS with Apache License 2.0 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);
    initFile();
    MapSdkWrapper.setCruiseChangeListener(onLocationListener);
    NetworkConnectChangedReceiver.setNetworkLtListener(onNetworkChangeListener);
    DateChangeReceiver.setDateChangeListener(onDateChangeListener);

    initView(view);
    if (mMapView != null) {
        mBaiduMap = mMapView.getMap();
    }
    if (NetworkUtil.isNetworkConnected(getActivity())) {
        initMap();
    } else if (mBaiduMap != null) {
        MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5);
        mBaiduMap.animateMapStatus(u);
    }
    return view;
}
 
Example 3
Source File: MainActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
/**
 * des:地图跳到指定位置
 *
 * @param location
 */
private void navigateTo(BDLocation location) {
    if (isFirstLocation) {
        LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll);
        baiduMap.animateMapStatus(update);
        update = MapStatusUpdateFactory.zoomTo(18f);
        baiduMap.animateMapStatus(update);
        isFirstLocation = false;
    }
    MyLocationData.Builder builder = new MyLocationData.Builder();
    builder.latitude(location.getLatitude());
    builder.longitude(location.getLongitude());
    MyLocationData data = builder.build();
    baiduMap.setMyLocationData(data);
}
 
Example 4
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initMap() {
    //ricky init baidumap begin
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    mMapView.showZoomControls(false);
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);
    mBaiduMap.setMapStatus(msu);
    mBaiduMap.setOnMapTouchListener(touchListener);
    // 初始化POI信息列表
    mInfoList = new ArrayList<PoiInfo>();
    // 初始化当前MapView中心屏幕坐标,初始化当前地理坐标
    mCenterPoint = mBaiduMap.getMapStatus().targetScreen;
    mLoactionLatLng = mBaiduMap.getMapStatus().target;
    // 定位
    mBaiduMap.setMyLocationEnabled(true);
    // 隐藏百度logo ZoomControl
    int count = mMapView.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ImageView || child instanceof ZoomControls) {
            child.setVisibility(View.INVISIBLE);
        }
    }
    // 隐藏比例尺
    //mMapView.showScaleControl(false);
    // 地理编码

    mGeoCoder = GeoCoder.newInstance();
    mGeoCoder.setOnGetGeoCodeResultListener(GeoListener);
    list = (ListView) findViewById(R.id.list);
    list.setOnItemClickListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    loading = (ProgressBar) findViewById(R.id.loading);
    status = (TextView) findViewById(R.id.status);
    mAdapter = new MapPickerAdapter(MapPickerActivity.this, mInfoList);
    list.setAdapter(mAdapter);
}
 
Example 5
Source File: MapActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
private void initView() {
	// 获取地图控件引用
	mMapView = (MapView) findViewById(R.id.bmapView);
	// 改变显示的比例尺
	mBaiduMap = mMapView.getMap();
	MapStatusUpdate after = MapStatusUpdateFactory.zoomTo(15.0f);
	mBaiduMap.setMapStatus(after);

}
 
Example 6
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 7
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");
}