com.baidu.mapapi.map.MapStatusUpdateFactory Java Examples

The following examples show how to use com.baidu.mapapi.map.MapStatusUpdateFactory. 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: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example #2
Source File: FreightTrackGoogleMapFragment.java    From ESeal with Apache License 2.0 6 votes vote down vote up
/**
 * 自适应百度地图显示大小
 */
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));
}
 
Example #3
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 #4
Source File: OverlayManager.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
/**
 * 缩放地图,使所有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());
            } else if (overlay instanceof Polyline) {
                Polyline polyline = (Polyline) overlay;
                if (null != polyline.getPoints() && !polyline.getPoints().isEmpty()) {
                    builder.include(polyline.getPoints().get(0));
                    builder.include(polyline.getPoints().get((polyline.getPoints().size() - 1) / 2));
                    if (polyline.getPoints().size() > 2) {
                        builder.include(polyline.getPoints().get(polyline.getPoints().size() - 1));
                    }
                }
            }
        }
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngBounds(builder.build()));
    }
}
 
Example #5
Source File: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 6 votes vote down vote up
/**
 * 根据获取到的位置在地图上移动“我”的位置
 *
 * @param location
 */
private void navigateTo(BDLocation location) {
    double longitude = location.getLongitude();
    double latitude = location.getLatitude();
    String address = location.getAddrStr();
    if (isFirstLocation) {
        currentLatLng = new LatLng(latitude, longitude);
        MapStatus.Builder builder = new MapStatus.Builder();
        MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build();
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory
                .newMapStatus(mapStatus));
        isFirstLocation = false;

        //反向地理解析(含有poi列表)
        mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption()
                .location(currentLatLng));
    }
    MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData = locationBuilder.build();
    mBaiduMap.setMyLocationData(locationData);
}
 
Example #6
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 6 votes vote down vote up
/**
 * 根据收货地址的位置在地图上移动"我"的位置
 */
private void navigateTo(double longitude, double latitude) {
	if (isFirstLocation) {
		currentLatLng = new LatLng(latitude, longitude);
		MapStatus.Builder builder = new MapStatus.Builder();
		MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build();
		mBaiduMap.animateMapStatus(MapStatusUpdateFactory
				.newMapStatus(mapStatus));
		isFirstLocation = false;

		//反向地理解析(含有poi列表)
		mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption()
				.location(currentLatLng));
	}
	MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
	locationBuilder.latitude(latitude);
	locationBuilder.longitude(longitude);
	MyLocationData locationData = locationBuilder.build();
	mBaiduMap.setMyLocationData(locationData);
}
 
Example #7
Source File: FreightTrackMapFragment.java    From ESeal with Apache License 2.0 6 votes vote down vote up
/**
 * 自适应百度地图显示大小
 */
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));
}
 
Example #8
Source File: OverlayManager.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
/**
 * 缩放地图,使所有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());
            }
        }
        MapStatus mapStatus = mBaiduMap.getMapStatus();
        if (null != mapStatus){
            int width = mapStatus.winRound.right - mBaiduMap.getMapStatus().winRound.left - 400;
            int height = mapStatus.winRound.bottom - mBaiduMap.getMapStatus().winRound.top - 400;
            mBaiduMap.setMapStatus(MapStatusUpdateFactory
                    .newLatLngBounds(builder.build(), width, height));
        }

    }
}
 
Example #9
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 #10
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 #11
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 6 votes vote down vote up
/**
 * 根据获取到的位置在地图上移动"我"的位置
 *
 * @param location
 */
private void navigateTo(BDLocation location) {
	double longitude = location.getLongitude();
	double latitude = location.getLatitude();
	String address = location.getAddrStr();
	if (isFirstLocation) {
		currentLatLng = new LatLng(latitude, longitude);
		MapStatus.Builder builder = new MapStatus.Builder();
		MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build();
		mBaiduMap.animateMapStatus(MapStatusUpdateFactory
				.newMapStatus(mapStatus));
		isFirstLocation = false;

		//反向地理解析(含有poi列表)
		mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption()
				.location(currentLatLng)
				.radius(radius));
	}
	MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
	locationBuilder.latitude(location.getLatitude());
	locationBuilder.longitude(location.getLongitude());
	MyLocationData locationData = locationBuilder.build();
	mBaiduMap.setMyLocationData(locationData);
}
 
Example #12
Source File: MainActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
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()));
}
 
Example #13
Source File: MainActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
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);
        }

    }
}
 
Example #14
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 #15
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 #16
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example #17
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 缩放地图,使所有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();
        }
    }
}
 
Example #18
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example #19
Source File: OverlayManager.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
/**
 * 设置显示在规定宽高中的地图地理范围
 */
public void zoomToSpanPaddingBounds(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
    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(), paddingLeft, paddingTop, paddingRight, paddingBottom));
    }
}
 
Example #20
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example #21
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
    // 通知是适配器第position个item被选择了
    mAdapter.setNotifyTip(position);
    mAdapter.notifyDataSetChanged();
    BitmapDescriptor mSelectIco = BitmapDescriptorFactory
            .fromResource(R.drawable.picker_map_geo_icon);
    mBaiduMap.clear();
    PoiInfo info = (PoiInfo) mAdapter.getItem(position);
    LatLng la = info.location;
    // 动画跳转
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(la);
    mBaiduMap.animateMapStatus(u);
    // 添加覆盖物
    OverlayOptions ooA = new MarkerOptions().position(la)
            .icon(mSelectIco).anchor(0.5f, 0.5f);
    mBaiduMap.addOverlay(ooA);
    mLoactionLatLng = info.location;
    mAddress = info.address;
    mName = info.name;
    mCity = info.city;

    mLatitude = info.location.latitude;
    mLongitude = info.location.longitude;
    mStreet = info.name;//地图对应位置文字描述
}
 
Example #22
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 定位接收到的地址
 **/
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));
}
 
Example #23
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 #24
Source File: TrafficShowActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #25
Source File: Activity_Location.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
private void navigateTo(BDLocation location) {
    longitude = location.getLongitude();
    latitude = location.getLatitude();
    tv_longitude.setText(longitude + "");
    tv_latitude.setText(latitude + "");
    address = location.getAddrStr();
    tv_address.setText(address);
    if (isFirstLocation) {
        latLng = new LatLng(latitude, longitude);
        MapStatus.Builder builder = new MapStatus.Builder();
        MapStatus mapStatus = builder.target(latLng).zoom(15.0f).build();
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory
                .newMapStatus(mapStatus));
        isFirstLocation = false;
    }
    MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData = locationBuilder.build();
    mBaiduMap.setMyLocationData(locationData);
}
 
Example #26
Source File: OverlayManager.java    From Mobike with Apache License 2.0 6 votes vote down vote up
/**
 * 缩放地图,使所有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()));
    }
}
 
Example #27
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public void turnBack() {
    MyLocationData location = mBaiduMap.getLocationData();

    if (location == null) {
        return;
    }
    // 实现动画跳转
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(new LatLng(location.latitude, location.longitude));
    mBaiduMap.animateMapStatus(u);
    mBaiduMap.clear();
    // 发起反地理编码检索
    mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption())
            .location(new LatLng(location.latitude, location.longitude)));

}
 
Example #28
Source File: MainActivity.java    From VirtualLocation with Apache License 2.0 5 votes vote down vote up
/**
 * setCurrentMapLatLng 设置当前坐标
 */
public static void setCurrentMapLatLng(LatLng arg0) {
    curLatlng = arg0;
    mMarker.setPosition(arg0);

    // 设置地图中心点为这是位置
    LatLng ll = new LatLng(arg0.latitude, arg0.longitude);
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
    mBaiduMap.animateMapStatus(u);

    // 根据经纬度坐标 找到实地信息,会在接口onGetReverseGeoCodeResult中呈现结果
    mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(arg0));
}
 
Example #29
Source File: FreightTrackGoogleMapFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
private void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #30
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
private void setPoiPosition() {
    if (aList.size() == 0 || poiOverlay == null)
        return;
    if (aList.size() == 1) {
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(new LatLng(aList.get(0).getLatitude(), aList.get(0).getLongitude()))
                .targetScreen(new Point(baiduMap.getMapStatus().targetScreen.x, baiduMap.getMapStatus().targetScreen.y / 4))
                .zoom(17F);
        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    } else
        poiOverlay.zoomToSpan();
}