Java 类com.baidu.mapapi.map.MapStatusUpdateFactory 实例源码

项目:AssistantBySDK    文件:SetFavoriteMapActivity.java   
/**
 * 定位接收到的地址
 **/
private void locationReceiveAddress() {
    if (receiveAddress == null) {
        return;
    }
    LatLng p = new LatLng(receiveAddress.getLatitude(), receiveAddress.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    /* 设置覆盖物图标 */
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_openmap_focuse_mark))
            .position(p)
            .visible(true);
    baiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            setSinglePoiDetail();
            return true;
        }
    });
    if (NetUtil.getInstance(SetFavoriteMapActivity.this).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) {
        // Snackbar.make(mAmosfPoiList,mAppConfig.getResources().getString(R.string.no_network), Snackbar.LENGTH_SHORT).show();
        return;
    }
    /* 添加覆盖图层 */
    baiduMap.addOverlay(markerOptions);
    baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(p, 17F));
}
项目:GitHub    文件:OverlayManager.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:GitHub    文件:MainActivity.java   
private void cancelBook() {
    countDownTimer.cancel();
    bike_layout.setVisibility(View.GONE);
    bike_info_layout.setVisibility(View.GONE);
    confirm_cancel_layout.setVisibility(View.GONE);
    prompt.setVisibility(View.GONE);
    bike_distance_layout.setVisibility(View.VISIBLE);
    bike_distance_layout.setVisibility(View.VISIBLE);
    book_bt.setVisibility(View.VISIBLE);
    if (routeOverlay != null)
        routeOverlay.removeFromMap();
    MapStatus.Builder builder = new MapStatus.Builder();
    //地图缩放比设置为18
    builder.target(currentLL).zoom(18.0f);
    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
}
项目:DaiGo    文件:SeeLocationActivity.java   
private void initView() {
    mapView = (MapView) findViewById(R.id.see_location_mapview);
    toolBarView = (ToolBarView) findViewById(R.id.see_location_toolbar);

    toolBarView.setBackButtonImage(R.mipmap.icon_back);
    toolBarView.setBackButtonVisible(true);
    toolBarView.setBackButtonOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    toolBarView.setTitleText("查看接单人位置");

    baiduMap = mapView.getMap();

    MapStatusUpdate update = MapStatusUpdateFactory.zoomTo(19f);
    baiduMap.setMapStatus(update);

    handler = new MyHandler(this);


}
项目:DaiGo    文件:SeeLocationActivity.java   
@Override
public void handleMessage(Message msg) {
    final SeeLocationActivity activity = activityWeakReference.get();
    switch (msg.what) {
        case 0:
            final String response = (String) msg.obj;

            Scanner scanner = new Scanner(response);
            double latitude = Double.parseDouble(scanner.next());
            double longitude = Double.parseDouble(scanner.next());
            LatLng point = new LatLng(latitude, longitude);
            if (activity.centP == null) {
                activity.centP = point;
                activity.baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(activity.centP));
            }
            activity.initHeadBitmap();
            OverlayOptions options = new MarkerOptions().position(point).icon(activity.bitmapDescriptor);
            activity.baiduMap.clear();
            activity.baiduMap.addOverlay(options);
            break;
    }
}
项目:TYT    文件:CB_BaiduMapActivity.java   
/**
 * 初始化百度地图
 */
private void initBaiduMap() {
    // 设置是否显示缩放控件
    mMapView.showZoomControls(false);
    mBaiduMap = mMapView.getMap();
    // 设定地图中心点坐标:宁波天翔货柜有限公司(云台山路)
    LatLng point = new LatLng(29.882673, 121.894326);
    // 以动画方式更新地图状态,动画耗时默认 300 ms ,地图支持的最大最小级别分别为[3-21]
    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(point, 18));
    // 定义Maker坐标点:宁波天翔货柜有限公司(云台山路)
    ArrayList<BitmapDescriptor> giflist = new ArrayList<>();
    giflist.add(BitmapDescriptorFactory.fromResource(R.mipmap.ic_marker));
    giflist.add(BitmapDescriptorFactory.fromResource(R.mipmap.ic_marker_light));
    // 通过marker的icons设置一组图片,再通过period设置多少帧刷新一次图片资源
    MarkerOptions mo = new MarkerOptions().position(point).icons(giflist).zIndex(0).period(20);
    // 设置生长动画/掉下动画
    // mo.animateType(MarkerOptions.MarkerAnimateType.drop);
    // 在地图上添加Marker,并显示
    mBaiduMap.addOverlay(mo);
}
项目:AssistantBySDK    文件:TrafficShowActivity.java   
private void initView() {
    //设置模拟状态栏的高度
    ViewGroup.LayoutParams layoutParams = mStatusBar.getLayoutParams();
    layoutParams.height = ScreenUtil.getStatusBarHeight(this);
    mStatusBar.setLayoutParams(layoutParams);

    baiduMap = mapView.getMap();
    /* 是否显示比例尺控件 */
    mapView.showScaleControl(true);
    /* 是否显示缩放控件 */
    mapView.showZoomControls(false);
    baiduMap = mapView.getMap();
    /* 是否允许定位图层 */
    baiduMap.setMyLocationEnabled(true);
    /* 设置缩放级别,改变地图状态 */
    baiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(17f));
    mNaviDao = BaiduNaviDao.getInstance();
    /* 获取家和单位地址 */
    homeAddress = mNaviDao.getHomeOrCompanyAddress(getResources().getString(R.string.home));
    companyAddress = mNaviDao.getHomeOrCompanyAddress(getResources().getString(R.string.company));
}
项目:AssistantBySDK    文件:SetFavoriteMapActivity.java   
@Override
public void zoomToSpan() {
    if (mAmosfMap != null) {
        try {
            mAmosfMap.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ConfirmCustomPoiOverlay.super.zoomToSpan();
                    if (mAmosfPoiBox.getVisibility() == View.VISIBLE) {
                        MapStatus ms = baiduMap.getMapStatus();
                        ms.targetScreen.set(ScreenUtil.getInstance().getWidthPixels() / 2, ScreenUtil.getInstance().getHeightPixels() / 4);
                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(ms));
                    }
                }
            }, 300);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:AssistantBySDK    文件:SetFavoriteMapActivity.java   
@Override
public void zoomToSpan() {
    if (mAmosfMap != null) {
        try {
            mAmosfMap.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ConfirmPoiOverlay.super.zoomToSpan();
                    if (mAmosfPoiBox.getVisibility() == View.VISIBLE) {
                        MapStatus ms = baiduMap.getMapStatus();
                        ms.targetScreen.set(ScreenUtil.getInstance().getWidthPixels() / 2, ScreenUtil.getInstance().getHeightPixels() / 4);
                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(ms));
                    }
                }
            }, 300);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:AssistantBySDK    文件:NaviConfirmPointActivity.java   
@Override
public void zoomToSpan() {
    if (mAncpMap != null) {
        try {
            mAncpMap.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ConfirmCustomPoiOverlay.super.zoomToSpan();
                    if (mAncpPoiBox.getVisibility() == View.VISIBLE) {
                        MapStatus ms = baiduMap.getMapStatus();
                        ms.targetScreen.set(ScreenUtil.getInstance().getWidthPixels() / 2, ScreenUtil.getInstance().getHeightPixels() / 4);
                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(ms));
                    }
                }
            }, 500);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:AssistantBySDK    文件:NaviConfirmPointActivity.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 **/
@Override
public void zoomToSpan() {
    if (mAncpMap != null) {
        try {
            mAncpMap.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ConfirmPoiOverlay.super.zoomToSpan();
                    if (mAncpPoiBox.getVisibility() == View.VISIBLE) {
                        MapStatus ms = baiduMap.getMapStatus();
                        /* 设置地图操作中心点在屏幕中的坐标 */
                        ms.targetScreen.set(ScreenUtil.getInstance().getWidthPixels() / 2, ScreenUtil.getInstance().getHeightPixels() / 4);
                        /* 以动画的方式更新地图状态,耗时300ms */
                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(ms));
                    }
                }
            }, 500);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:AssistantBySDK    文件:TrafficShowPresenter.java   
@Override
public void zoomToSpan() {
    if (mapView != null) {
        try {
            mapView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ConfirmPoiOverlay.super.zoomToSpan();
                    if (mTrafficShowView.getPoiListBox().getVisibility() == View.VISIBLE) {
                        MapStatus ms = baiduMap.getMapStatus();
                        ms.targetScreen.set(ScreenUtil.getInstance().getWidthPixels() / 2, ScreenUtil.getInstance().getHeightPixels() / 4);
                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(ms));
                    }
                }
            }, 300);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:AssistantBySDK    文件:TrafficShowPresenter.java   
@Override
public void zoomToSpan() {
    if (mapView != null) {
        try {
            mapView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ConfirmCustomPoiOverlay.super.zoomToSpan();
                    if (mTrafficShowView.getPoiListBox().getVisibility() == View.VISIBLE) {
                        MapStatus ms = baiduMap.getMapStatus();
                        ms.targetScreen.set(ScreenUtil.getInstance().getWidthPixels() / 2, ScreenUtil.getInstance().getHeightPixels() / 4);
                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(ms));
                    }
                }
            }, 300);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:RunHDU    文件:RunningActivity.java   
private void stopRunning() {
    runningStatus = 2;
    timer.stop();
    client.stop();

    startButton.setIdleText("跑步结束");
    startButton.setProgress(0);

    if (!pointList.isEmpty()) {
        addMarker(pointList.get(pointList.size() - 1), R.drawable.ic_loc_end);
    }

    msUpdate = MapStatusUpdateFactory.newMapStatus(
            new MapStatus.Builder().zoom(17).build()
    );
    baiduMap.setMapStatus(msUpdate);

    locTimes = 0;//重置定位次数

    stepSensor.unregisterStep();
    saveRunData();

    // 计算平均速度
    float speed = Integer.parseInt(distanceNumber.getNumber()) / getSeconds();
    speedNumber.setText(Utility.formatDecimal(speed, 2));
}
项目:SmartButler    文件:LocationActivity.java   
private void moveToMe(BDLocation location)
{
    MapStatusUpdate mapUpdate=MapStatusUpdateFactory.zoomTo(18);
    baiduMap.setMapStatus(mapUpdate);
    //开始移动
    MapStatusUpdate mapLatlng=MapStatusUpdateFactory.newLatLng(new LatLng(location.getLatitude(),location.getLongitude()));
    baiduMap.setMapStatus(mapLatlng);
    //显示我的位置
    MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData=locationBuilder.build();
    baiduMap.setMyLocationData(locationData);
    //显示用户所在地附近
    Toast.makeText(this,"您当前在"+location.getAddrStr()+"附近",Toast.LENGTH_SHORT).show();
}
项目:Tribe    文件:NearbyFragment.java   
private void initMapSetting() {

        mMapView.showZoomControls(false);

        mBaiduMap = mMapView.getMap();
        // 开启定位图层
        mBaiduMap.setMyLocationEnabled(true);
        //设置指南针
//        UiSettings uiSettings = mBaiduMap.getUiSettings();
//        uiSettings.setCompassEnabled(true);

        mBaiduMap.setCompassPosition(new Point(660,60));

        //设置普通地图
        mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
        //设置定位图层配置信息,只有先允许定位图层后设置定位图层配置信息才会生效
        mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(
                MyLocationConfiguration.LocationMode.NORMAL, false, null));
        mBaiduMap.setBuildingsEnabled(false);

        //设置缩放级别
        MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(16.0f);
        mBaiduMap.setMapStatus(msu);

    }
项目:VirtualLocation    文件:MainActivity.java   
/**
 * 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();
}
项目:MaterialLearning    文件:BaiduMapActivity.java   
public void navigateTo(BDLocation location){
    if(isFirstLocate){
        LatLng latLng=new LatLng(location.getLatitude(),location.getLongitude());
        showToast("定位到当前位置已执行");

        MapStatusUpdate    update=MapStatusUpdateFactory.zoomTo(8f);
        baiduMap.animateMapStatus(update);
        update= MapStatusUpdateFactory.newLatLng(latLng);
        baiduMap.animateMapStatus(update);

       isFirstLocate=false;
    }
    MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    baiduMap.setMyLocationData(locationBuilder.build());

}
项目:wzyx-android-user    文件:BaiduMapActivity.java   
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    mLastLocationData=bdLocation;
    MyLocationData myLocationData=new MyLocationData.Builder()
            .accuracy(bdLocation.getRadius())
            .latitude(bdLocation.getLatitude())
            .longitude(bdLocation.getLongitude())
            .build();
    mBaiduMap.setMyLocationData(myLocationData);
    MapStatusUpdate msu1 = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu1);

    if(isFirstIn){
        LatLng ll=new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude());
        MapStatusUpdate msu=MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.setMapStatus(msu);
        isFirstIn=false;
    }
}
项目:GCSApp    文件:LocationDemo.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null) {
        return;
    }
    mCurrentLat = location.getLatitude();
    mCurrentLon = location.getLongitude();
    mCurrentAccracy = location.getRadius();
    locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(mCurrentDirection).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:GCSApp    文件:RoutePlanDemo.java   
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_routeplan);
        mTvtitle = (TextView) findViewById(R.id.tv_topbar_title);
        mTvtitle.setText("财神谷地址");
        ImageView img = (ImageView) findViewById(R.id.img_topbar_back);
        img.setImageResource(R.mipmap.icon_back);
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                RoutePlanDemo.this.finish();
            }
        });
//        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);//获取传感器管理服务
        // 初始化地图
        mMapView = (MapView) findViewById(R.id.map);
        mBaidumap = mMapView.getMap();
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.zoom(18.0f);
        builder.target(new LatLng(29.184662, 121.305024));
        mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build());
        mBaidumap.setMapStatus(mMapStatusUpdate);
        MarkerOptions ooA = new MarkerOptions().position(GEO_NINGBO).icon(bdA)
                .zIndex(9).draggable(true);
        mBaidumap.addOverlay(ooA);
        mBaidumap.setTrafficEnabled(true);
        findViewById(R.id.lin_action_route).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                go2ThirdMap();
            }
        });
    }
项目:GCSApp    文件:OverlayManager.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:Mobike    文件:OverlayManager.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:Mobike    文件:MainActivity.java   
public void onMapStatusChangeFinish(MapStatus mapStatus) {
    String _str = mapStatus.toString();
    String _regex = "target lat: (.*)\ntarget lng";
    String _regex2 = "target lng: (.*)\ntarget screen x";
    changeLatitude = Double.parseDouble(latlng(_regex, _str));
    changeLongitude = Double.parseDouble(latlng(_regex2, _str));
    LatLng changeLL = new LatLng(changeLatitude, changeLongitude);
    startNodeStr = PlanNode.withLocation(changeLL);
    Log.d(TAG, "changeLatitude-----change--------" + changeLatitude);
    Log.d(TAG, "changeLongitude-----change--------" + changeLongitude);
    if (!isNeedCurrentlocation) {
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(changeLL);
        baiduMap.setMapStatus(u);
        if (Math.hypot((changeLatitude - currentLatitude),
                (changeLongitude - currentLongitude)) > 0.00001) {
            Logger.d(Math.hypot((changeLatitude - currentLatitude),
                    (changeLongitude - currentLongitude)));
            if (routeOverlay != null)
                routeOverlay.removeFromMap();
            addOverLayout(changeLatitude, changeLongitude);
        }

    }
}
项目:Mobike    文件:MainActivity.java   
private void cancelBook() {
    if (isNeedLogin) {
        mLogin.setVisibility(View.VISIBLE);
    } else {
        mLogin.setVisibility(View.GONE);
    }
    mBikeInfoBoard.setVisibility(View.GONE);
    countDownTimer.cancel();
    mBikeOrderBoard.setVisibility(View.GONE);
    //        confirm_cancel_layout.setVisibility(View.GONE);
    //        prompt.setVisibility(View.GONE);
    //        bike_distance_layout.setVisibility(View.VISIBLE);
    //        bike_distance_layout.setVisibility(View.VISIBLE);
    mBtLoginOrorder.setVisibility(View.VISIBLE);
    if (routeOverlay != null)
        routeOverlay.removeFromMap();
    MapStatus.Builder builder = new MapStatus.Builder();
    //地图缩放比设置为18
    builder.target(currentLL).zoom(18.0f);
    baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
}
项目:Mobike    文件:MainActivity.java   
/**
 * 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);
}
项目:AndroidOpen    文件:OverlayManager.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:Swap    文件:OverlayManager.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:ChangTu    文件:TrackActivity.java   
/**
 * 画出实时线路点
 *
 * @param point
 */
private void drawRealtimePoint(LatLng point) {
    Log.i("TGA", "绘制成功");
    mBaiduMap.clear();
    MapStatus mapStatus = new MapStatus.Builder().target(point).zoom(18).build();
    msUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
    realtimeBitmap = BitmapDescriptorFactory.fromResource(R.drawable.ct_map_location);
    overlay = new MarkerOptions().position(point)
            .icon(realtimeBitmap).zIndex(9).draggable(true);


    if (pointList.size() >= 2 && pointList.size() <= 6000) {
        polyline = new PolylineOptions().width(10).color(Color.GREEN).points(pointList);
    }

    addMarker();
}
项目:MapLocation    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null) {
        return;
    }
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        applicate=(Myapplication)getApplication();
        applicate.setLon(location.getLongitude());
        applicate.setLat(location.getLatitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:SmartTransXA    文件:BusLineOnlineActivity.java   
private void initViews() {
    mBtnPre = (Button) findViewById(R.id.btn_busline_pre);
    mBtnNext = (Button) findViewById(R.id.btn_busline_next);
    mBtnPre.setVisibility(View.INVISIBLE);
    mBtnNext.setVisibility(View.INVISIBLE);
    etRouteOnline = (EditText) findViewById(R.id.et_route_online);
    mBaiduMap = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.bmapView)).getBaiduMap();
    // �趨��ͼ��ʼ���ĵ����꣨�����ʵ��ѧ����У����
    LatLng xayd = new LatLng(34.162719, 108.907775);
    // �趨��ͼ״̬���趨��ʼ���ĵ�����ż�����
    MapStatus mMapStatus = new MapStatus.Builder().target(xayd).zoom(12)
            .build();
    // ����MapStatusUpdate�����Ա�������ͼ״̬��Ҫ�����ı仯
    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory
            .newMapStatus(mMapStatus);

    // ���õ�ͼ״̬
    mBaiduMap.setMapStatus(mMapStatusUpdate);

}
项目:SmartTransXA    文件:OverlayManager.java   
/**
 * ���ŵ�ͼ��ʹ����Overlay���ں��ʵ���Ұ��
 * <p>
 * ע�� �÷���ֻ��Marker���͵�overlay��Ч
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
             // polyline �еĵ����̫�ֻ࣬��marker ����
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:MyCar    文件:OverlayManager.java   
/**
 * 缩放地图,使所有Overlay都在合适的视野内
 * <p>
 * 注: 该方法只对Marker类型的overlay有效
 * </p>
 * 
 */
public void zoomToSpan() {
    if (mBaiduMap == null) {
        return;
    }
    if (mOverlayList.size() > 0) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Overlay overlay : mOverlayList) {
            // polyline 中的点可能太多,只按marker 缩放
            if (overlay instanceof Marker) {
                builder.include(((Marker) overlay).getPosition());
            }
        }
        mBaiduMap.setMapStatus(MapStatusUpdateFactory
                .newLatLngBounds(builder.build()));
    }
}
项目:mvpChat    文件:MapPresenterImpl.java   
private void initBaiduMap() {
    mBaiduMap = mIMapView.getBaiduMap();
    //获取地图对象控制器
    mBaiduMap.setBuildingsEnabled(true);//设置显示楼体
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(19f));//设置地图状态
    mUiSettings = mBaiduMap.getUiSettings();
    mUiSettings.setZoomGesturesEnabled(true);
    mUiSettings.setScrollGesturesEnabled(true);
    mUiSettings.setRotateGesturesEnabled(true);
    mUiSettings.setOverlookingGesturesEnabled(true);
    mUiSettings.setCompassEnabled(true);
    MapStatus ms = new MapStatus.Builder().overlook(30).build();
    MapStatusUpdate u = MapStatusUpdateFactory.newMapStatus(ms);
    mBaiduMap.animateMapStatus(u, 1000);
    // 初始化搜索模块
    mSearch = GeoCoder.newInstance();
    mSearch.setOnGetGeoCodeResultListener(this);
}
项目:ESeal    文件:FreightTrackBaiduMapFragment.java   
/**
 * 自适应百度地图显示大小
 */
private void setBaiduMapAdaptedZoom(List<LatLng> polylines) {
    if (polylines == null || polylines.size() == 0) return;

    double minLat = polylines.get(0).latitude;
    double maxLat = polylines.get(0).latitude;
    double minLng = polylines.get(0).longitude;
    double maxLng = polylines.get(0).longitude;

    LatLng point;
    for (int i = 1; i < polylines.size(); i++) {
        point = polylines.get(i);
        if (point.latitude < minLat) minLat = point.latitude;
        if (point.latitude > maxLat) maxLat = point.latitude;
        if (point.longitude < minLng) minLng = point.longitude;
        if (point.longitude > maxLng) maxLng = point.longitude;
    }

    double centerLat = (maxLat + minLat) / 2;
    double centerLng = (maxLng + minLng) / 2;
    LatLng centerLatLng = new LatLng(centerLat, centerLng);

    float zoom = getZoom(minLat, maxLat, minLng, maxLng);
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(centerLatLng, zoom));
}
项目:ESeal    文件:FreightTrackMapWithWebViewFragment.java   
/**
 * 自适应百度地图显示大小
 */
private void setBaiduMapAdaptedZoom(List<LatLng> polylines) {
    if (polylines == null || polylines.size() == 0) return;

    double minLat = polylines.get(0).latitude;
    double maxLat = polylines.get(0).latitude;
    double minLng = polylines.get(0).longitude;
    double maxLng = polylines.get(0).longitude;

    LatLng point;
    for (int i = 1; i < polylines.size(); i++) {
        point = polylines.get(i);
        if (point.latitude < minLat) minLat = point.latitude;
        if (point.latitude > maxLat) maxLat = point.latitude;
        if (point.longitude < minLng) minLng = point.longitude;
        if (point.longitude > maxLng) maxLng = point.longitude;
    }

    double centerLat = (maxLat + minLat) / 2;
    double centerLng = (maxLng + minLng) / 2;
    LatLng centerLatLng = new LatLng(centerLat, centerLng);

    float zoom = getZoom(minLat, maxLat, minLng, maxLng);
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(centerLatLng, zoom));
}
项目:ESeal    文件:FreightTrackMapFragment.java   
/**
 * 自适应百度地图显示大小
 */
private void setBaiduMapAdaptedZoom(List<LatLng> polylines) {
    if (polylines == null || polylines.size() == 0) return;

    double minLat = polylines.get(0).latitude;
    double maxLat = polylines.get(0).latitude;
    double minLng = polylines.get(0).longitude;
    double maxLng = polylines.get(0).longitude;

    LatLng point;
    for (int i = 1; i < polylines.size(); i++) {
        point = polylines.get(i);
        if (point.latitude < minLat) minLat = point.latitude;
        if (point.latitude > maxLat) maxLat = point.latitude;
        if (point.longitude < minLng) minLng = point.longitude;
        if (point.longitude > maxLng) maxLng = point.longitude;
    }

    double centerLat = (maxLat + minLat) / 2;
    double centerLng = (maxLng + minLng) / 2;
    LatLng centerLatLng = new LatLng(centerLat, centerLng);

    float zoom = getZoom(minLat, maxLat, minLng, maxLng);
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(centerLatLng, zoom));
}
项目:ESeal    文件:FreightTrackGoogleMapFragment.java   
/**
 * 自适应百度地图显示大小
 */
private void setBaiduMapAdaptedZoom(List<LatLng> polylines) {
    if (polylines == null || polylines.size() == 0) return;

    double minLat = polylines.get(0).latitude;
    double maxLat = polylines.get(0).latitude;
    double minLng = polylines.get(0).longitude;
    double maxLng = polylines.get(0).longitude;

    LatLng point;
    for (int i = 1; i < polylines.size(); i++) {
        point = polylines.get(i);
        if (point.latitude < minLat) minLat = point.latitude;
        if (point.latitude > maxLat) maxLat = point.latitude;
        if (point.longitude < minLng) minLng = point.longitude;
        if (point.longitude > maxLng) maxLng = point.longitude;
    }

    double centerLat = (maxLat + minLat) / 2;
    double centerLng = (maxLng + minLng) / 2;
    LatLng centerLatLng = new LatLng(centerLat, centerLng);

    float zoom = getZoom(minLat, maxLat, minLng, maxLng);
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(centerLatLng, zoom));
}
项目:MapForTour    文件:MapFragment.java   
@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;
}
项目:MapForTour    文件:MapFragment.java   
@Override
public boolean onMarkerClick(Marker marker) {
    Log.d("lml", "MapFragment:覆盖物被点击");
    baiduMap.hideInfoWindow();
    if (marker != null) {
        latLngshow = marker.getPosition();
        reverseGeoCodeOption.location(latLngshow);
        geoCoder.reverseGeoCode(reverseGeoCodeOption);
        tvAddOverlayGeoCoder.setText("正在获取详细位置");
        bundle = marker.getExtraInfo();

        generalIsMale = bundle.getString("general").equals("m");
        layoutAddOverlayRadarNearbyItem.setBackgroundColor(getResources().getColor(generalIsMale ? R.color.blue : R.color.pink));
        imageViewAddOverlayItem.setImageResource(generalIsMale ? R.mipmap.map_portrait_man : R.mipmap.map_portrait_woman);
        tvAddOverlayItemUserID.setText(bundle.getString("userID"));
        tvAddOverlayItemDistance.setText("距离" + bundle.getInt("distance") + "米        ");
        tvAddOverlayItemLatlng.setText("坐标:   " + latLngshow.latitude + "  ,  " + latLngshow.longitude + "           ");
        Log.d("lml", "MapFragment显示的信息:" + bundle.getString("userID"));
        Log.d("lml", bundle.getString("general") + ";" + generalIsMale);
        baiduMap.showInfoWindow(new InfoWindow(viewOverlayItem, marker.getPosition(), -70));
        MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(marker.getPosition());
        baiduMap.animateMapStatus(update);
        return true;
    } else
        return false;
}