Java Code Examples for com.baidu.mapapi.map.MyLocationData#Builder

The following examples show how to use com.baidu.mapapi.map.MyLocationData#Builder . 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: 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 2
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 3
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 4
Source File: ShareLocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    MyLocationData data;
    MyLocationData.Builder builder = new MyLocationData.Builder();
    if (baiduMap != null) {
        data = builder.direction(bdLocation.getDirection())
                .latitude(bdLocation.getLatitude())
                .longitude(bdLocation.getLongitude())
                .direction(bdLocation.getDirection())
                .build();
        baiduMap.setMyLocationData(data);
        addOverLay(myId,new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude()),bdLocation.getDirection());

        ShareLocationData locationData = new ShareLocationData();
        locationData.direction = Double.toString( bdLocation.getDirection());
        locationData.latitude = Double.toString(bdLocation.getLatitude());
        locationData.longitude = Double.toString(bdLocation.getLongitude());
        if (!inited){
            //第一次收到消息自动缩放地图
            inited = true;
            zoomMap();
        }
        presenter.sendLocationData(locationData);
    }
}
 
Example 5
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 6
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 7
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQS_LOCATION:
            if (RESULT_OK == resultCode) {
                PoiObject info = (PoiObject) data.getSerializableExtra("PoiObject");
                Logger.d(info);
                LatLng latLng = new LatLng(Double.parseDouble(info.lattitude),
                        Double.parseDouble(info.longitude));
                isNeedCurrentlocation = false;
                MyLocationData.Builder builder = new MyLocationData.Builder();
                builder.latitude(latLng.latitude);
                builder.longitude(latLng.longitude);
                MyLocationData build = builder.build();
                baiduMap.setMyLocationData(build);
                //                    MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
                //                    baiduMap.setMapStatus(msu);
                if (routeOverlay != null)
                    routeOverlay.removeFromMap();
                addOverLayout(latLng.latitude, latLng.longitude);
            }
            break;
        case REQS_UNLOCK:
            if (RESULT_OK == resultCode) {
                ToastUtils.show(MainActivity.this, data.getStringExtra("result"));
                beginService();
            }

            break;
    }
}