This article describes how to use the Baidu map API in Android applications step-by-step through a simple example.
1) Download Baidu map mobile version API (Android) Development Package
To use the Baidu map API in Android applications, you need to quote the Baidu Map API development package in the project, which contains two files: Baidumapapi.jar and libbmapapiengine.so. Download Address: Http://dev.baidu.com/wiki/static/imap/files/BaiduMapApi_Lib_Android_1.0.zip
2) Application API Key
As with the Google Map API, you need to get the appropriate API Key before using the Baidu maps API. Baidu Map API Key is associated with your Baidu account, so you must have Baidu account before you can get API key, and this key is related to the program name you reference the API.
Baidu API Key application is much simpler than Google, in fact, as long as you have Baidu account, should not exceed 30 seconds to complete the API key application. Application Address: http://dev.baidu.com/wiki/static/imap/key/
3 Create an Android project
Here is a point to emphasize: Baidu Map Mobile version API support Android 1.5 and above system, so we create the project should be based on the Android SDK 1.5 and above.
After the project is created, the Baidumapapi.jar and libbmapapiengine.so are copied to the engineering root directory and Libs/armeabi directory, and the engineering properties->java build path-> Libraries Select "Add JARs", selected Baidumapapi.jar, so you can use the Baidu Map API in the application. The complete directory structure of the project is shown in the following illustration:
4 Add a map control to the layout file (res/layout/main.xml)
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:orientation=" vertical "
android:layout_width=" fill_parent "
android:layout_" height= "Fill_parent"
>
<com.baidu.mapapi.mapview android:id= "@+id/map_view"
android:layout_ Width= "Fill_parent"
android:layout_height= "fill_parent"
android:clickable= "true"
/>
</ Linearlayout>