本文整理汇总了Java中com.baidu.mapapi.map.MyLocationConfiguration.LocationMode.FOLLOWING属性的典型用法代码示例。如果您正苦于以下问题:Java LocationMode.FOLLOWING属性的具体用法?Java LocationMode.FOLLOWING怎么用?Java LocationMode.FOLLOWING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.baidu.mapapi.map.MyLocationConfiguration.LocationMode
的用法示例。
在下文中一共展示了LocationMode.FOLLOWING属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.id_map_common:
// 普通地图
mbaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
break;
case R.id.id_map_site:
// 卫星地图
mbaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
break;
case R.id.id_map_traffic:
// 实时交通图
if (mbaiduMap.isTrafficEnabled()) {
mbaiduMap.setTrafficEnabled(false);
item.setTitle("实时交通(OFF)");
} else {
mbaiduMap.setTrafficEnabled(true);
item.setTitle("实时交通(ON)");
}
break;
case R.id.id_map_location:
// 我的位置
centerToMyLocation();
break;
case R.id.id_map_mocknav:
// 模拟导航
if (mDestLocation != null) {
routeplanToNavi(false);
} else {
Toast.makeText(getApplicationContext(), "请先设置目标", 0).show();
}
break;
case R.id.id_map_realnav:
// 开始导航
if (mDestLocation != null) {
routeplanToNavi(true);
} else {
Toast.makeText(getApplicationContext(), "请先设置目标", 0).show();
}
break;
case R.id.id_map_mode_common:
locationmode = LocationMode.NORMAL;
break;
case R.id.id_map_mode_following:
locationmode = LocationMode.FOLLOWING;
break;
case R.id.id_map_mode_compass:
locationmode = LocationMode.COMPASS;
break;
case R.id.id_add_overlay:
addOverlays(Info.infos);
break;
case R.id.id_remove_overlay:
for (int i = 0; i < list.size(); i++) {
list.get(i).remove();
}
list.clear();
break;
case R.id.id_map_hot:
// 开启交通图
if (mbaiduMap.isBaiduHeatMapEnabled()) {
mbaiduMap.setBaiduHeatMapEnabled(false);
item.setTitle("关闭热力地图(OFF)");
} else {
mbaiduMap.setBaiduHeatMapEnabled(true);
item.setTitle("关闭热力地图(ON)");
}
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
示例2: onOptionsItemSelected
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
// if (id == R.id.action_settings) {
// return true;
// }
int item_id = item.getItemId();
// int isDisplayScreen = getWindow().getAttributes().flags;
switch (item_id) {
case R.id.map_common:
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
break;
case R.id.map_satellite:
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
break;
case R.id.map_traffic:
if (mBaiduMap.isTrafficEnabled()) {
mBaiduMap.setTrafficEnabled(false);
item.setTitle("交通地图(on)");
} else {
mBaiduMap.setTrafficEnabled(true);
item.setTitle("交通地图(off)");
}
break;
case R.id.map_heat:
if (mBaiduMap.isBaiduHeatMapEnabled()) {
mBaiduMap.setBaiduHeatMapEnabled(false);
item.setTitle("热力图(on)");
} else {
mBaiduMap.setBaiduHeatMapEnabled(true);
item.setTitle("热力图(off)");
}
break;
case R.id.display_fullscreen:
if (isDisplayScreen == false) {// 当前非全屏,设置成全屏
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// 此处不能取消标题栏,否则会出错;
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
isDisplayScreen = true;
item.setTitle("关闭全屏");
} else {// 当前全屏,设置成非全屏
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN);
item.setTitle("打开全屏");
isDisplayScreen = false;
}
break;
case R.id.id_map_location:
centerToMyLocation();
break;
case R.id.id_map_mode_common:
mLocationMode = LocationMode.NORMAL;
break;
case R.id.id_map_mode_following:
mLocationMode = LocationMode.FOLLOWING;
break;
case R.id.id_map_mode_compass:
mLocationMode = LocationMode.COMPASS;
break;
}
return super.onOptionsItemSelected(item);
}
示例3: onCreateView
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
viewMap = inflater
.inflate(R.layout.activity_location, container, false);
requestLocButton = (Button) viewMap.findViewById(R.id.button1);
mCurrentMode = LocationMode.NORMAL;
requestLocButton.setText("定位");
OnClickListener btnClickListener = new OnClickListener() {
public void onClick(View v) {
switch (mCurrentMode) {
case NORMAL:
// Intent intent = new Intent(LocationActivity.this,
// RoutePlan.class);
// startActivity(intent);
// finish();
requestLocButton.setText("跟随");
mCurrentMode = LocationMode.FOLLOWING;
mBaiduMap
.setMyLocationConfigeration(new MyLocationConfiguration(
mCurrentMode, true, mCurrentMarker));
break;
case COMPASS:
requestLocButton.setText("普通");
mCurrentMode = LocationMode.NORMAL;
mBaiduMap
.setMyLocationConfigeration(new MyLocationConfiguration(
mCurrentMode, true, mCurrentMarker));
break;
case FOLLOWING:
requestLocButton.setText("罗盘");
mCurrentMode = LocationMode.COMPASS;
mBaiduMap
.setMyLocationConfigeration(new MyLocationConfiguration(
mCurrentMode, true, mCurrentMarker));
break;
}
}
};
requestLocButton.setOnClickListener(btnClickListener);
// 地图初始化
mMapView = (MapView) viewMap.findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
bdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);
bdD = BitmapDescriptorFactory.fromResource(R.drawable.icon_markd);
// 开启定位图层
mBaiduMap.setMyLocationEnabled(true);
// 定位初始化
mLocClient = new LocationClient(viewMap.getContext());
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
mLocClient.setLocOption(option);
mLocClient.start();
return viewMap;
}
示例4: onCreateView
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
viewMap = inflater
.inflate(R.layout.activity_location, container, false);
requestLocButton = (Button) viewMap.findViewById(R.id.button1);
mCurrentMode = LocationMode.NORMAL;
requestLocButton.setText("定位");
OnClickListener btnClickListener = new OnClickListener() {
public void onClick(View v) {
switch (mCurrentMode) {
case NORMAL:
// Intent intent = new Intent(LocationActivity.this,
// RoutePlan.class);
// startActivity(intent);
// finish();
requestLocButton.setText("跟随");
mCurrentMode = LocationMode.FOLLOWING;
mBaiduMap
.setMyLocationConfigeration(new MyLocationConfiguration(
mCurrentMode, true, mCurrentMarker));
break;
case COMPASS:
requestLocButton.setText("普通");
mCurrentMode = LocationMode.NORMAL;
mBaiduMap
.setMyLocationConfigeration(new MyLocationConfiguration(
mCurrentMode, true, mCurrentMarker));
break;
case FOLLOWING:
requestLocButton.setText("罗盘");
mCurrentMode = LocationMode.COMPASS;
mBaiduMap
.setMyLocationConfigeration(new MyLocationConfiguration(
mCurrentMode, true, mCurrentMarker));
break;
}
}
};
requestLocButton.setOnClickListener(btnClickListener);
// 地图初始化
mMapView = (MapView) viewMap.findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
bdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);
bdD = BitmapDescriptorFactory.fromResource(R.drawable.icon_markd);
// 开启定位图层
mBaiduMap.setMyLocationEnabled(true);
// 定位初始化
mLocClient = new LocationClient(viewMap.getContext());
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
mLocClient.setLocOption(option);
mLocClient.start();
getMarkerLocation();
return viewMap;
}
示例5: onOptionsItemSelected
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// ��ͨ
case R.id.map_common:
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
break;
// ����
case R.id.map_site:
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
break;
// ʵʱ
case R.id.map_traffic:
// �Ƿ���ʾ��ʵʱ��ͼ
if (mBaiduMap.isTrafficEnabled()) {
mBaiduMap.setTrafficEnabled(false);
item.setTitle("ʵʱ��ͨoff");
} else {
mBaiduMap.setTrafficEnabled(true);
item.setTitle("ʵʱ��ͨon");
}
break;
// �ҵ�λ��
case R.id.map_location:
centerToMyLocation();
break;
// ��ͨģʽ
case R.id.map_sensormode_normal:
mLocationMode = LocationMode.NORMAL;
break;
// ����ģʽ
case R.id.map_sensormode_following:
mLocationMode = LocationMode.FOLLOWING;
break;
// ����ģʽ
case R.id.map_sensormode_compass:
mLocationMode = LocationMode.COMPASS;
break;
// ������
case R.id.map_add_overlay:
addOverlay(getMarkerData());
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
示例6: onCreate
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_near);
allInc = (List<Incident>) getIntent().getBundleExtra("bundle")
.getSerializable("allInc");
troubleMaker = new ArrayList<Marker>();
crowdMaker = new ArrayList<Marker>();
clearMaker = new ArrayList<Marker>();
controlMaker = new ArrayList<Marker>();
initCheckBoxes();
locationMode = LocationMode.FOLLOWING;
bitmapDescriptor = null;
mapView = (MapView) findViewById(R.id.map_near);
baiduMap = mapView.getMap();
baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
locationMode, true, bitmapDescriptor));
baiduMap.setMyLocationEnabled(true);
baiduMap.setOnMarkerClickListener(new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker arg0) {
String type = arg0.getTitle();
String addr = arg0.getExtraInfo().getString("addr");
Button bubble = new Button(getApplicationContext());
bubble.setBackgroundResource(R.drawable.popup);
bubble.setText("类型:" + type + "\n" + "地点:" + addr);
InfoWindow window = new InfoWindow(bubble, arg0.getPosition(),
-70);
baiduMap.showInfoWindow(window);
return true;
}
});
locationClient = new LocationClient(this);
locationClient.registerLocationListener(new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (location == null || mapView == null)
return;
MyLocationData locationData = new MyLocationData.Builder()
.accuracy(location.getRadius()).direction(100)
.latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
baiduMap.setMyLocationData(locationData);
if (isFirstLoc) {
isFirstLoc = false;
LatLng ll = new LatLng(location.getLatitude(), location
.getLongitude());
MapStatusUpdate update = MapStatusUpdateFactory
.newLatLng(ll);
baiduMap.animateMapStatus(update);
}
}
});
LocationClientOption clientOption = new LocationClientOption();
clientOption.setOpenGps(true);
clientOption.setCoorType("bd09ll");
clientOption.setScanSpan(1000);
locationClient.setLocOption(clientOption);
locationClient.start();
addSignals();
}