Using the Baidu Map API in Android apps

Source: Internet
Author: User
Tags imap root directory

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.