标签:android 百度地图 fragment地图 supportmap
SupportMapFragment 类,管理地图生命周期。
构造器和说明:
SupportMapFragment()
构造函数
限定符和类型 | 方法 | 说明 |
---|---|---|
BaiduMap | getBaiduMap() | 获取百度地图控制器,当执行完 onCreateView 函数之后调用,否则返回 null. |
MapView | getMapView() | 获取百度地图控件 |
static SupportMapFragment | newInstance() | 创建一个MapFragment实例 |
static SupportMapFragment | newInstance(BaiduMapOptions options) | 根据给定的百度地图选项创建一个SupportMapFragment 实例 |
void | onActivityCreated(Bundle savedInstanceState) | * |
void | onAttach(Activity activity) | * |
void | onConfigurationChanged(Configuration newConfig) | 当配置发送改变的时候会被调用 |
void | onCreate(Bundle savedInstanceState) | * |
View | onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) | * |
void | onDestroy() | * |
void | onDestroyView() | * |
void | onDetach() | * |
void | onPause() | * |
void | onResume() | * |
void | onSaveInstanceState(Bundle outState) | * |
void | onStart() | * |
void | onStop() | * |
void | onViewCreated(View view, Bundle savedInstanceState) | * |
void | onViewStateRestored(Bundle savedInstanceState) | * |
创建 activity_fragment.xml
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fm_map"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
</LinearLayout>
创建 MapFragmentDemo
类继承 BaseActivity :
public class MapFragmentDemo extends BaseActivity {
private SupportMapFragment map;
private FragmentManager fm;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment);
//overlook:俯视角;zoom:缩放
MapStatus ms = new MapStatus.Builder().overlook(-20).zoom(15).build();
//compassEnabled是否开启指南针;zoomControlsEnabled:是否按比例缩放;
BaiduMapOptions bo = new BaiduMapOptions().mapStatus(ms).compassEnabled(false).zoomControlsEnabled(false);
map = SupportMapFragment.newInstance(bo);
fm = getSupportFragmentManager();
fm.beginTransaction().add(R.id.fm_map, map, "map_fragemnt").commit();
}
}
运行效果图:
版权声明:本文为博主原创文章,未经博主允许不得转载。
Android中级篇之百度地图SDK v3.5.0-FragmentMap地图框架[图解SupportMapFragment类]
标签:android 百度地图 fragment地图 supportmap
原文地址:http://blog.csdn.net/y1scp/article/details/48154185