Android Baidu positioning is displayed on the map. Click the pop-up bubble. android bubble

Source: Internet
Author: User
Tags ontap

Android Baidu positioning is displayed on the map. Click the pop-up bubble. android bubble

1. Apply for a key on the Baidu map page. Note that the key corresponds to the project package name and digital signature one by one. Http://developer.baidu.com/map/index.php? Title = % E9 % A6 % 96% E9 % A1 % B5

2. Download the corresponding sdk package: http://lbsyun.baidu.com/sdk/download

3. Create a project and add the corresponding package

 

Add development keys and required permissions to AndroidManifest;

(1) Add a development Key to the application

<Application <meta-data android: name = "com. baidu. lbsapi. API_KEY" android: value = "Developer key"/>
   <service            android:name="com.baidu.location.f"            android:enabled="true"            android:process=":remote" >        </service></application>

2) Add 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 =" Droid. 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 =" andro Id. permission. READ_SMS "/> <uses-permission android: name =" android. permission. SEND_SMS "/> <! -- SDK1.5 requires the permission of android. permission. GET_TASKS to determine whether the program is the currently running application? --> <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 cancel --> <uses-permission android: name = "android. permission. process_outgoing_cils "> </uses-permission> <uses-permission android: name =" android. permission. READ_PHONE_STATE "/> <uses-permission android: name =" android. permission. MODIFY_AUDIO_SETTINGS "/>
 

Step 3: add the layout file. Use the LinearLayout in the code to add the 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.MapView      android:id="@+id/bmapView"      android:layout_width="fill_parent"      android:layout_height="fill_parent"      android:clickable="true" />

First, we can set some configuration information in the Code, such as removing the zoom control.

 

Main Code:

 

 

Complete demo: http://download.csdn.net/detail/hhhccckkk/7962441

 

 

How can I directly display the content in the bubble when I call a Baidu map ??

You can use a custom class to display bubbles, and then set a pop-up window in onTap (int index) of the custom class to solve this problem!

@ Override
Public boolean onTap (int index ){

// Process the item click event here

LayoutInflater inflater = LayoutInflater. from (mapView. getContext ());
View view = inflater. inflate (R. layout. reserve_warning_pop, null );

TextView TV _reservewarning_pop_parkinglotname = (TextView) view. findViewById (R. id. TV _reservewarning_pop_parkinglotname );
TextView TV _reservewarning_pop_parkinglotaddress = (TextView) view. findViewById (R. id. TV _reservewarning_pop_parkinglotaddress );
TextView TV _reservewarning_pop_parkinglotcurrentstall = (TextView) view. findViewById (R. id. TV _reservewarning_pop_parkinglotcurrentstall );
TextView TV _reservewarning_pop_parkinglotprice = (TextView) view. findViewById (R. id. TV _reservewarning_pop_parkinglotprice );

If (parkingLot! = Null ){
// Parking lot name

// Parking address

// Reserved parking space

// Parking lot charge type
}

// Reservation button
Button bt_reservewarning_pop_reserve = (Button) view. findViewById (R. id. bt_reservewarning_pop_reserve );

Bt_reservewarning_pop_reserve.setOnClickListener (new View. OnClickListener (){

@ Override
Public void onClick (View v ){

// Business processing}

}
}
});

// The Custom page is displayed.
PopupOverlay = new PopupOverlay (mapView, null );

OverlayItem overlayItem = getItem (index );

MapView. getController (). setCenter (overlayItem. getPoint ());

PopupOverlay. showPopup (view, overlayItem. getPoint (), 5 );

Baidu map for android Development

Make a judgment and change it to false after one click.
Make MapView. refresh ()


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.