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

The following examples show how to use com.baidu.mapapi.map.MapStatusUpdateFactory#newLatLngZoom() . 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: 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 2
Source File: EaseBaiduMapActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
private void showMap(double latitude, double longtitude, String address) {
	sendButton.setVisibility(View.GONE);
	LatLng llA = new LatLng(latitude, longtitude);
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.ease_icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example 3
Source File: EaseBaiduMapActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
	if (location == null) {
		return;
	}
	Log.d("map", "On location change received:" + location);
	Log.d("map", "addr:" + location.getAddrStr());
	sendButton.setEnabled(true);
	if (progressDialog != null) {
		progressDialog.dismiss();
	}

	if (lastLocation != null) {
		if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
			Log.d("map", "same location, skip refresh");
			// mMapView.refresh(); //need this refresh?
			return;
		}
	}
	lastLocation = location;
	mBaiduMap.clear();
	LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.ease_icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example 4
Source File: MapFragment.java    From MapForTour with MIT License 5 votes vote down vote up
public void setBaiduMapLocationData(MyLocationData locData) {
    baiduMap.setMyLocationData(locData);
    if (isFirstLocate) {
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2);
        baiduMap.animateMapStatus(u);//动画移动摄像头
        isFirstLocate = false;
    }
    Log.d("lml", "MapFragment - 设置一次位置");
}
 
Example 5
Source File: EaseBaiduMapActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void showMap(double latitude, double longtitude, String address) {
	sendButton.setVisibility(View.GONE);
	LatLng llA = new LatLng(latitude, longtitude);
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.ease_icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example 6
Source File: EaseBaiduMapActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
	if (location == null) {
		return;
	}
	Log.d("map", "On location change received:" + location);
	Log.d("map", "addr:" + location.getAddrStr());
	sendButton.setEnabled(true);
	if (progressDialog != null) {
		progressDialog.dismiss();
	}

	if (lastLocation != null) {
		if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
			Log.d("map", "same location, skip refresh");
			// mMapView.refresh(); //need this refresh?
			return;
		}
	}
	lastLocation = location;
	mBaiduMap.clear();
	LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.ease_icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example 7
Source File: BaiduMapActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void showMap(double latitude, double longtitude, String address) {
	sendButton.setVisibility(View.GONE);
	LatLng llA = new LatLng(latitude, longtitude);
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example 8
Source File: BaiduMapActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
	if (location == null) {
		return;
	}
	Log.d("map", "On location change received:" + location);
	Log.d("map", "addr:" + location.getAddrStr());
	sendButton.setEnabled(true);
	if (progressDialog != null) {
		progressDialog.dismiss();
	}

	if (lastLocation != null) {
		if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
			Log.d("map", "same location, skip refresh");
			// mMapView.refresh(); //need this refresh?
			return;
		}
	}
	lastLocation = location;
	mBaiduMap.clear();
	LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example 9
Source File: MainActivity.java    From MoveMapLocation with Apache License 2.0 4 votes vote down vote up
/**
 * 定位监听
 *
 * @param bdLocation
 */
@Override
public void onReceiveLocation(BDLocation bdLocation) {

    //如果bdLocation为空或mapView销毁后不再处理新数据接收的位置
    if (bdLocation == null || mBaiduMap == null) {
        return;
    }

    //定位数据
    MyLocationData data = new MyLocationData.Builder()
            //定位精度bdLocation.getRadius()
            .accuracy(bdLocation.getRadius())
                    //此处设置开发者获取到的方向信息,顺时针0-360
            .direction(bdLocation.getDirection())
                    //经度
            .latitude(bdLocation.getLatitude())
                    //纬度
            .longitude(bdLocation.getLongitude())
                    //构建
            .build();

    //设置定位数据
    mBaiduMap.setMyLocationData(data);

    //是否是第一次定位
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLngZoom(ll, 18);
        mBaiduMap.animateMapStatus(msu);
    }

    //获取坐标,待会用于POI信息点与定位的距离
    locationLatLng = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude());
    //获取城市,待会用于POISearch
    city = bdLocation.getCity();

    //文本输入框改变监听,必须在定位完成之后
    searchAddress.addTextChangedListener(this);

    //创建GeoCoder实例对象
    geoCoder = GeoCoder.newInstance();
    //发起反地理编码请求(经纬度->地址信息)
    ReverseGeoCodeOption reverseGeoCodeOption = new ReverseGeoCodeOption();
    //设置反地理编码位置坐标
    reverseGeoCodeOption.location(new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()));
    geoCoder.reverseGeoCode(reverseGeoCodeOption);

    //设置查询结果监听者
    geoCoder.setOnGetGeoCodeResultListener(this);
}