Baidu Map API Usage Series 2-Show Map

Source: Internet
Author: User

Start the application of Baidu map

First, you should download the SDK provided to us by Baidu, including the Development Kit sample code API

Sign in below address

Http://developer.baidu.com/map/index.php?title=%E9%A6%96%E9%A1%B5






These are based on their own development needs of their own decision to download, the situation allows all download is not much

1. Import the class library files required by the project

Unpack the development package

Enter the Libs directory below this jar needs

and the bottom-level library goes under the Armeabi directory.

A jar package is also required if you use the to locate feature

2. Configure developer key in the manifest file

<meta-data

Android:name= "Com.baidu.lbsapi.API_KEY"

Android:value= "The developer who introduced the application in the previous section, key"/>

The location of this node in the manifest file

3. Add Permissions

<uses-permissionandroid:name= "Android.permission.GET_ACCOUNTS"/>

<uses-permissionandroid:name= "Android.permission.USE_CREDENTIALS"/>

<uses-permissionandroid:name= "Android.permission.MANAGE_ACCOUNTS"/>

<uses-permissionandroid:name= "Android.permission.AUTHENTICATE_ACCOUNTS"/>

<uses-permissionandroid:name= "Android.permission.ACCESS_NETWORK_STATE"/>

<uses-permissionandroid:name= "Android.permission.INTERNET"/>

<uses-permissionandroid:name= "Com.android.launcher.permission.READ_SETTINGS"/>

<uses-permissionandroid:name= "Android.permission.CHANGE_WIFI_STATE"/>

<uses-permissionandroid:name= "Android.permission.ACCESS_WIFI_STATE"/>

<uses-permissionandroid:name= "Android.permission.READ_PHONE_STATE"/>

<uses-permissionandroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permissionandroid:name= "Android.permission.BROADCAST_STICKY"/>

<uses-permissionandroid:name= "Android.permission.WRITE_SETTINGS"/>

<uses-permissionandroid:name= "Android.permission.READ_PHONE_STATE"/>

4. Add the Baidu map control to the layout file

< com.baidu.mapapi.map.mapview
        android :id= "@ +ID/BAIDU_MV "
        android :layout_width= "match_parent"
        android : layout_height= "match_parent"
;
Span style= "background: #EFEFEF" ></ Com.baidu.mapapi.map.MapView ;

5.1 Show Map

Activity (for now, consider only the activity that follows fragment) incoming ApplicationContext initialization map before build initialization

Sdkinitializer.initialize (Getapplicationcontext ());

The best way to Cook is to customize a application in this to implement the above method

6. Managing the life cycle of a map

Onresume

OnPause

Ondestory

@OverrideSuperbaidumapview. Onresume ();} @Override  Superbaidumapview. OnPause ();} @Override  Superbaidumapview. OnDestroy ();}

By now we can show the map on the interface and we'll do the map again later.

The source code of the program is attached below

Click to open link

Baidu Map API Usage Series 2-Show Map

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.