Android Baidu positioning after display on the map to click the pop bubble

Source: Internet
Author: User

1. Go to the Baidu Map page to apply for key, note that key and project package name and digital signature one by one correspond. Http://developer.baidu.com/map/index.php?title=%E9%A6%96%E9%A1%B5

2. Download the appropriate SDK package: Http://lbsyun.baidu.com/sdk/download

3. Create the project and add the appropriate package

Add the development key, required permissions and other information in androidmanifest;

(1) Add a development key in application

<   application  <   Meta-  data android:   name   < Span style= "COLOR: #339933" >=    "com.baidu.lbsapi.API_ KEY "  android:   value< Span style= "COLOR: #339933" >=    "developer Key"   Span class= "sy0" >/>   
   <service android:name= "COM.BAIDU.LOCATION.F" android:enabled= "true" android:process= ": Remote > </service></application>

2) Add the required permissions

<permission android:name= "Android.permission.BAIDU_LOCATION_SERVICE" >    </permission >    <uses-permission android:name= "Android.permission.BAIDU_LOCATION_SERVICE" >     </uses-permission>    <uses-permission android:name= " Android.permission.ACCESS_NETWORK_STATE ">    </uses-permission>    < Uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION" >    </ uses-permission>    <uses-permission android:name= "Android.permission.INTERNET" >     </uses-permission>    <uses-permission android:name= " Android.permission.ACCESS_MOCK_LOCATION ">    </uses-permission>    <!- -<uses-permission android:name= "Android.permission.WRITE_APN_SETTINGS" ></uses-permission>-     <uses-permission Android:name= "anDroid.permission.ACCESS_FINE_LOCATION ">    </uses-permission>    < Uses-permission android:name= "Com.android.launcher.permission.READ_SETTINGS"/>    < Uses-permission android:name= "Android.permission.WAKE_LOCK" >    </uses-permission>     <uses-permission android:name= "Android.permission.CHANGE_WIFI_STATE"/>    < Uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>    <uses-permission Android:name= "Android.permission.ACCESS_GPS"/>    <uses-permission android:name= " Android.permission.READ_PHONE_STATE "/>    <uses-permission android:name=" Android.permission.READ_CONTACTS "/>    <uses-permission android:name=" Android.permission.CALL_PHONE "/>    <uses-permission android:name=" android.permission.READ_ SMS "/>    <uses-permissIon Android:name= "Android.permission.SEND_SMS"/>    <!--SDK1.5 need android.permission.GET_ Tasks permissions to determine whether this program is currently running applications? -->    <uses-permission android:name= "Android.permission.GET_TASKS"/>    <uses-permission android:name= "Android.permission.CAMERA" >    </uses-permission>     <uses-permission android:name= "Android.permission.RECORD_AUDIO" >    </ uses-permission>    <uses-permission android:name= "android.permission.WRITE_EXTERNAL_ STORAGE ">    </uses-permission>    <uses-permission android:name=" Android.permission.RECEIVE_BOOT_COMPLETED "/>    <uses-permission android:name=" Android.permission.BROADCAST_STICKY "/>    <uses-permission android:name=" Android.permission.WRITE_SETTINGS "/>    <!--call silencing-->    < Uses-permission andRoid:name= "Android.permission.PROCESS_OUTGOING_CALLS" >    </uses-permission>     <uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>    < Uses-permission android:name= "Android.permission.MODIFY_AUDIO_SETTINGS"/>

The third step, add the layout file, the code inside use the LinearLayout to add Mapview

<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 ">

<linearlayout android:id= "@+id/map"

Android:layout_width= "Fill_parent" android:layout_height= "fill_parent" android:orientation= "vertical" > </LinearLayout>

</RelativeLayout>

You can also do this:

<Com.Baidu.Mapapi.Map.MapviewAndroid:Id="@+id/bmapview"Android:Layout_width="Fill_parent"Android:Layout_height="Fill_parent"Android:Clickable="true" />

The first is that we can set some configuration information in the code, such as removing the zoom control

Main code:

Full Demo:

Android Baidu positioning after display on the map to click the pop bubble

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.