com.baidu.mapapi.map.MyLocationData Java Examples

The following examples show how to use com.baidu.mapapi.map.MyLocationData. 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 apollo-DuerOS with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationChange(double latBd09ll, double lonBd09ll, double radBd09ll, double direction) {
    if (tvLa != null && tvLn != null) {
        Message message = Message.obtain();
        message.what = UPDATE_COARSE;
        Bundle bundle = new Bundle();
        bundle.putDouble("la", latBd09ll);
        bundle.putDouble("ln", lonBd09ll);
        message.setData(bundle);
        mHandler.sendMessage(message);
    }
    if (mMapView == null || mBaiduMap == null || (doubleEqual(mCurrentLat - latBd09ll) && doubleEqual(
            mCurrentLon - lonBd09ll))) {
        return;
    }
    mCurrentAccracy = (float) radBd09ll;
    mCurrentLat = latBd09ll;
    mCurrentLon = lonBd09ll;
    locData = new MyLocationData.Builder().accuracy((float) radBd09ll)
            .direction((float) direction).latitude(latBd09ll).longitude(lonBd09ll).build();
    mBaiduMap.setMyLocationData(locData);
}
 
Example #2
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 #3
Source File: LocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    MyLocationData data;
    Builder builder = new Builder();
    Logger.i(TAG + ":" + "addstr:" + bdLocation.getAddrStr()
            + "\n" + "latitude:" + bdLocation.getLatitude()
            + "\n" + "longitude:" + bdLocation.getLongitude()
            + "\n" + "coortype:" + bdLocation.getCoorType());
    if (baiduMap != null) {
        data = builder.direction(bdLocation.getDirection())
                .latitude(bdLocation.getLatitude())
                .longitude(bdLocation.getLongitude())
                .build();
        baiduMap.setMyLocationData(data);
        latitude = bdLocation.getLatitude();
        longitude = bdLocation.getLongitude();
        address = bdLocation.getAddress().address;
        mNewActionBar.getRightText().setClickable(true);
    }
    if (bundle.getInt(Constants.BundleKey.LOCATION_TYPE) == TYPE_SEND) {
        startLocationAndSetIcon();
    }

}
 
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: MapActivity.java    From foodie-app with Apache License 2.0 5 votes vote down vote up
private void startLocationOverlap() {
    //开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    //构造定位数据
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(mLocation.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(mLocation.getLatitude())
            .longitude(mLocation.getLongitude()).build();
    // 设置定位数据
    mBaiduMap.setMyLocationData(locData);
    // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
    //构建Marker图标
    BitmapDescriptor bitmap = BitmapDescriptorFactory
            .fromResource(R.drawable.my_location);
    //bitmap.
    MyLocationConfiguration config = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, bitmap);
    mBaiduMap.setMyLocationConfigeration(config);
    //中心点为我的位置
    LatLng cenpt = new LatLng(locData.latitude, locData.longitude);
    //定义地图状态
    MapStatus mMapStatus = new MapStatus.Builder()
            .target(cenpt)
            .zoom(mCurrentLevel)
            .build();
    //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
    //改变地图状态
    mBaiduMap.setMapStatus(mMapStatusUpdate);
    // 当不需要定位图层时关闭定位图层
    //mBaiduMap.setMyLocationEnabled(false);
}
 
Example #10
Source File: MapFragment.java    From apollo-DuerOS with Apache License 2.0 5 votes vote down vote up
@Override
public void onLocationChange(double latBd09ll, double lonBd09ll, double radBd09ll, double direction) {
    if (mMapView == null || mBaiduMap == null) {
        return;
    }
    if (doubleEqual(mCurrentLat - latBd09ll) && doubleEqual(mCurrentLon - lonBd09ll)) {
        return;
    }
    mCurrentAccracy = (float) radBd09ll;
    mCurrentLat = latBd09ll;
    mCurrentLon = lonBd09ll;
    locData = new MyLocationData.Builder().accuracy((float) radBd09ll)
            .direction((float) direction).latitude(latBd09ll).longitude(lonBd09ll).build();
    mBaiduMap.setMyLocationData(locData);
}
 
Example #11
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
    if (null != location && location.getLocType() != BDLocation.TypeServerError) {
        //

        MyLocationData data = new MyLocationData.Builder()//
                // .direction(mCurrentX)//
                .accuracy(location.getRadius())//
                .latitude(location.getLatitude())//
                .longitude(location.getLongitude())//
                .build();
        mBaiduMap.setMyLocationData(data);
        // 设置自定义图标
        MyLocationConfiguration config = new MyLocationConfiguration(
                MyLocationConfiguration.LocationMode.NORMAL, true, null);
        mBaiduMap.setMyLocationConfigeration(config);
        mAddress = location.getAddrStr();
        mName = location.getStreet();
        mCity = location.getCity();

        LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
        mLoactionLatLng = currentLatLng;
        // 是否第一次定位
        if (isFirstLoc) {
            isFirstLoc = false;
            // 实现动画跳转
            MapStatusUpdate u = MapStatusUpdateFactory
                    .newLatLng(currentLatLng);
            mBaiduMap.animateMapStatus(u);
            mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption())
                    .location(currentLatLng));
            return;
        }
    }

}
 
Example #12
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 #13
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;
    }
}
 
Example #14
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #15
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    if (bdLocation == null || baiduMap == null) {
        return;
    }
    mBDLocation = bdLocation;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(bdLocation.getRadius())
            .direction(mCurrentX)//设定图标方向     // 此处设置开发者获取到的方向信息,顺时针0-360
            .latitude(bdLocation.getLatitude())
            .longitude(bdLocation.getLongitude()).build();
    if (isNeedCurrentlocation)
        baiduMap.setMyLocationData(locData);
    currentLatitude = bdLocation.getLatitude();
    currentLongitude = bdLocation.getLongitude();
    mTvLocationInfo.setText(bdLocation.getAddrStr());
    currentLL = new LatLng(bdLocation.getLatitude(),
            bdLocation.getLongitude());
    MyLocationManager.getInstance().setCurrentLL(currentLL);
    MyLocationManager.getInstance().setAddress(bdLocation.getAddrStr());
    startNodeStr = PlanNode.withLocation(currentLL);
    //option.setScanSpan(5000),每隔5000ms这个方法就会调用一次,而有些我们只想调用一次,所以要判断一下isFirstLoc
    if (isFirstLocation) {
        isFirstLocation = false;
        LatLng ll = new LatLng(bdLocation.getLatitude(),
                bdLocation.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        //地图缩放比设置为18
        builder.target(ll).zoom(18.0f);
        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
        changeLatitude = bdLocation.getLatitude();
        changeLongitude = bdLocation.getLongitude();
        if (!isServiceLive) {
            addOverLayout(currentLatitude, currentLongitude);
        }
    }
}
 
Example #16
Source File: RouteBaiduBusActivity.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #17
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #18
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #19
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 #20
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #21
Source File: RouteBaiduBusActivity.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #22
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #23
Source File: LocationActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
	// map view 销毁后不在处理新接收的位置
	if (location == null || mMapView == null) return;

	if (lastLocation != null) {
		if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
			BmobLog.i("获取坐标相同");// 若两次请求获取到的地理位置坐标是相同的,则不再定位
			mLocClient.stop();
			return;
		}
	}
	lastLocation = location;

	BmobLog.i("lontitude = " + location.getLongitude() + ",latitude = " + location.getLatitude() + ",地址 = "
			+ lastLocation.getAddrStr());

	MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())
	// 此处设置开发者获取到的方向信息,顺时针0-360
			.direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build();
	mBaiduMap.setMyLocationData(locData);
	LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
	String address = location.getAddrStr();
	if (address != null && !address.equals("")) {
		lastLocation.setAddrStr(address);
	} else {
		// 反Geo搜索
		mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll));
	}
	// 显示在地图上
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
	mBaiduMap.animateMapStatus(u);
	// 设置按钮可点击
	// mHeaderLayout.getRightImageButton().setEnabled(true);
}
 
Example #24
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onOrientationChanged(float x) {
    mXDirection = (int) x;

    if (null != mBaiduMap && null != mBaiduMap.getLocationData()) {
        MyLocationData locData = new MyLocationData.Builder()
                .direction(mXDirection)
                .latitude(mBaiduMap.getLocationData().latitude)
                .longitude(mBaiduMap.getLocationData().longitude)
                .accuracy(mBaiduMap.getLocationData().accuracy)
                .build();
        mBaiduMap.setMyLocationData(locData);
    }
}
 
Example #25
Source File: ShareLocationActivity.java    From imsdk-android with MIT License 4 votes vote down vote up
private void zoomMap(){
    MyLocationData data = baiduMap.getLocationData();
    LatLng latLng = new LatLng(data.latitude, data.longitude);
    baiduMap.animateMapStatus(MapStatusUpdateFactory.zoomTo(15.6f));
    baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(latLng));
}
 
Example #26
Source File: MainActivity.java    From MapForTour with MIT License 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
  switch (intent.getAction()) {
    //实时位置信息收到广播
    case "cc.bitlight.broadcast.location.data": {
      NavigationViewItemLocateMode.setTitle("定位方式:" + application.getLocateMode());
      NavigationViewItemLongitude.setTitle("经度:" + application.getLongitude());
      NavigationViewItemLatitude.setTitle("纬度:" + application.getLatitude());
      NavigationViewItemRadius.setTitle("精度:" + application.getRadius() + "米");
      tvNavigationViewHeaderAddress.setText("当前位置:" + application.getAddress());
      MyLocationData locData = new MyLocationData.Builder()
          .accuracy(application.getRadius())
          .latitude(application.getLatitude())
          .longitude(application.getLongitude()).build();
      // 设置定位数据
      mapFragment.setBaiduMapLocationData(locData);
      Log.d("lml", "location.data接收到");
    }
    break;
    //实时周边信息收到广播
    case "cc.bitlight.broadcast.nearbyinfo.data": {
      List<MyRadarNearbyInfo> myRadarNearbyInfoList = application.getMyRadarNearbyInfoList();
      int infoListSize = myRadarNearbyInfoList.size();
      nearbyFragment.setRadarNearbyInfoList(myRadarNearbyInfoList, infoListSize);
      mapFragment.setRadarNearbyInfoList(myRadarNearbyInfoList, infoListSize);
      Log.d("lml", "nearbyinfo.data接收到 ;" + "NearbyFragment:输出尺寸list.size():" + infoListSize);
      Message message = new Message();
      message.what = MESSAGE_LOGIN_SUCCEED;
      handler.sendMessage(message);
    }
    break;
    //历史轨迹信息收到并请求绘制广播
    case "cc.bitlight.broadcast.track.historytrack.draw": {
      Log.d("lml", "track.historytrack.draw收到" + intent.getDoubleExtra("distance", 0));
      int distance = (int) intent.getDoubleExtra("distance", 0);
      NavigationViewItemTrackQuery.setTitle("轨迹查询:共" + distance + "米");
      mapFragment.polylineHistoryTrace = new PolylineOptions();
      mapFragment.refreshMapUI();
      toolbarOperateCloseTrackOrOpenColor(true);//标红toolbar中轨迹清除按钮
    }
    break;
    case "cc.bitlight.broadcast.geofence.reload":
      menuToolbarItemGeoFenceStatus.setTitle("围栏已开启");
      menuToolbarItemGeoFenceStatus.setIcon(R.mipmap.menu_toolbar_ic_geofence_on);
      int radius = intent.getIntExtra("radius", 0);
      LatLng latLng = new LatLng(intent.getDoubleExtra("latitude", 0), intent.getDoubleExtra("longitude", 0));
      mapFragment.createOrUpdateFenceShow(radius, latLng);
      break;
    case "cc.bitlight.broadcast.geofence.notification":
      String userID = intent.getStringExtra("userID");
      int fenceStatus = intent.getIntExtra("fenceStatus", 0);
      if (fenceStatus == 1) {
        snackbar = Snackbar.make(coordinatorLayoutContainer, "用户\"" + userID + "\"已进入了指定范围", Snackbar.LENGTH_LONG);
        snackbar.setAction("查看详情", new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            vp_FindFragment_pager.setCurrentItem(1);
          }
        });
        snackbar.show();
      }
      if (fenceStatus == 2) {
        snackbar = Snackbar.make(coordinatorLayoutContainer, "用户\"" + userID + "\"已离开了指定范围", Snackbar.LENGTH_LONG);
        snackbar.show();
      }
      break;
  }
}
 
Example #27
Source File: MapActivity.java    From BaiduMap-TrafficAssistant with MIT License 4 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {

	MyLocationData data = new MyLocationData.Builder()//
			.direction(mCurrentX)//
			.accuracy(location.getRadius())//
			.latitude(location.getLatitude())//
			.longitude(location.getLongitude())//
			.build();

	mBaiduMap.setMyLocationData(data);

	// 设置自定义图标
	MyLocationConfiguration config = new MyLocationConfiguration(
			mLocationMode, true, mIconLocation);
	mBaiduMap.setMyLocationConfigeration(config);

	// 更新经纬度
	mLatitude = location.getLatitude();
	mLongitude = location.getLongitude();

	if (isFirstIn) {
		LatLng latlng = new LatLng(location.getLatitude(),
				location.getLongitude());
		MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latlng);
		mBaiduMap.animateMapStatus(msu);
		isFirstIn = false;

		Toast.makeText(context, location.getAddrStr(),
				Toast.LENGTH_SHORT).show();
		Log.i("TAG",
				location.getAddrStr() + "\n" + location.getAltitude()
						+ "" + "\n" + location.getCity() + "\n"
						+ location.getCityCode() + "\n"
						+ location.getCoorType() + "\n"
						+ location.getDirection() + "\n"
						+ location.getDistrict() + "\n"
						+ location.getFloor() + "\n"
						+ location.getLatitude() + "\n"
						+ location.getLongitude() + "\n"
						+ location.getNetworkLocationType() + "\n"
						+ location.getProvince() + "\n"
						+ location.getSatelliteNumber() + "\n"
						+ location.getStreet() + "\n"
						+ location.getStreetNumber() + "\n"
						+ location.getTime() + "\n");

		// 弹出对话框显示定位信息;
		Builder builder = new Builder(context);
		builder.setTitle("为您获得的定位信息:");
		builder.setMessage("当前位置:" + location.getAddrStr() + "\n"
				+ "城市编号:" + location.getCityCode() + "\n" + "定位时间:"
				+ location.getTime() + "\n" + "当前纬度:"
				+ location.getLatitude() + "\n" + "当前经度:"
				+ location.getLongitude());
		builder.setPositiveButton("确定", null);
		AlertDialog alertDialog = builder.create();
		alertDialog.show();
	}// if
}
 
Example #28
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);
}
 
Example #29
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");
}
 
Example #30
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");
}