BaiduMap---百度地图官方Demo之UI控制功能(介绍开关手势功能和显示隐藏UI控件)
2015-07-02 11:13
633 查看
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="50dip" android:orientation="horizontal" > <CheckBox android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:checked="true" android:onClick="setZoomEnable" android:text="缩放" /> <CheckBox android:id="@+id/scroll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:checked="true" android:onClick="setScrollEnable" android:text="平移" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="50dip" android:orientation="horizontal" > <CheckBox android:id="@+id/rotate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:checked="true" android:onClick="setRotateEnable" android:text="旋转" /> <CheckBox android:id="@+id/overlook" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:checked="true" android:onClick="setOverlookEnable" android:text="俯视" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="50dip" android:orientation="horizontal" > <CheckBox android:id="@+id/compass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:checked="true" android:onClick="setCompassEnable" android:text="开启指南针" /> </LinearLayout> <com.baidu.mapapi.map.MapView android:id="@+id/bmapView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" /> </LinearLayout>
/** * 演示地图UI控制功能 * 介绍开关手势功能和显示隐藏UI控件 */ public class UISettingDemo extends Activity { /** * MapView 是地图主控件 */ private MapView mMapView; private BaiduMap mBaiduMap; //UiSettings:百度地图 UI 控制器 private UiSettings mUiSettings; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_uisetting); mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); /** * getUiSettings():获取地图ui控制器 * */ mUiSettings = mBaiduMap.getUiSettings(); MapStatus ms = new MapStatus.Builder().overlook(-30).build(); MapStatusUpdate u = MapStatusUpdateFactory.newMapStatus(ms); mBaiduMap.animateMapStatus(u, 1000); } /** * 是否启用缩放手势 * * @param v */ public void setZoomEnable(View v) { /** *setZoomGesturesEnabled(boolean enabled):设置是否允许缩放手势 * */ mUiSettings.setZoomGesturesEnabled(((CheckBox) v).isChecked()); } /** * 是否启用平移手势 * * @param v */ public void setScrollEnable(View v) { /** *setScrollGesturesEnabled(boolean enabled):设置是否允许拖拽手势 * */ mUiSettings.setScrollGesturesEnabled(((CheckBox) v).isChecked()); } /** * 是否启用旋转手势 * * @param v */ public void setRotateEnable(View v) { /** *setRotateGesturesEnabled(boolean enabled):设置是否允许旋转手势 * */ mUiSettings.setRotateGesturesEnabled(((CheckBox) v).isChecked()); } /** * 是否启用俯视手势 * * @param v */ public void setOverlookEnable(View v) { /** *setOverlookingGesturesEnabled(boolean enabled):设置是否允许俯视手势 * */ mUiSettings.setOverlookingGesturesEnabled(((CheckBox) v).isChecked()); } /** * 是否启用指南针图层 * * @param v */ public void setCompassEnable(View v) { /** *setCompassEnabled(boolean enabled):设置是否允许指南针 * */ mUiSettings.setCompassEnabled(((CheckBox) v).isChecked()); } @Override protected void onPause() { // MapView的生命周期与Activity同步,当activity挂起时需调用MapView.onPause() mMapView.onPause(); super.onPause(); } @Override protected void onResume() { // MapView的生命周期与Activity同步,当activity恢复时需调用MapView.onResume() mMapView.onResume(); super.onResume(); } @Override protected void onDestroy() { // MapView的生命周期与Activity同步,当activity销毁时需调用MapView.destroy() mMapView.onDestroy(); super.onDestroy(); } }
相关文章推荐
- soapui 免费版 实现 datasource+ dataLoop
- Guice 学习(九) WEB AND SERVLET
- ArduinoYun教程之OpenWrt-Yun与CLI配置Arduino Yun
- easy ui tree 默认选中指定行
- UIlabel特殊属性的使用
- UILabel特殊属性的使用
- 简述Java中,GUI的事件驱动模式
- 长时间停留在calculating requirements and dependencies 的解决方案
- 代码实现 UITableView与UITableViewCell
- ArduinoYun教程之OpenWrt-Yun与CLI配置Arduino Yun
- 线程——委托InvokeRequired和Invoke
- Build Action 设置为 Embedded Resource
- UI7法则
- 用 requirejs 的 R.js 打包css + js
- 1041. Be Unique (20)
- Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools
- Windows 10 Build 10158上手操作视频首发
- iOS9 UI Tests探索笔记
- UIScrollView新手教程
- 日志一:GUI的初始和GUI编程初步