百度地图3.7.1的配置

申请key,下载jar包。然后创建工程,把相对应的jar包拷贝到lib文件夹下,配置清单文件。

然后把百度地图的视图放到layout下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.baidu.mapapi.map.MapView
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:clickable="true">
    </com.baidu.mapapi.map.MapView>

</RelativeLayout>

最后在oncreate方法里进行初始化,这里的初始化必须在setContentView之前进行

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //去除标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //初始化百度地图
        SDKInitializer.initialize(getApplicationContext());
        setContentView(R.layout.activity_main);
    }

这时候就配置和完成了。

posted @ 2016-03-22 13:34  aaddrrooiidd  阅读(130)  评论(0编辑  收藏  举报