Android intermediate Baidu Map SDK V3.5.0-fragmentmap map Frame [graphic supportmapfragment class]

Source: Internet
Author: User

Create a fragment-based map frame
  • Supportmapfragment

    supportmapfragment class to manage the map life cycle.

  • Constructor overview

    Constructors and descriptions:

    SupportMapFragment()constructor function

  • Overview of methods
    Qualifiers and Types Method Description
    Baidumap Getbaidumap () Gets the Baidu map controller, called after executing the Oncreateview function, otherwise returns NULL.
    Mapview GetMapView () Get Baidu Map Control
    Static supportmapfragment Newinstance () Create a Mapfragment instance
    Static supportmapfragment Newinstance (baidumapoptions options) Create a Supportmapfragment instance based on the given Baidu map option
    void onactivitycreated (Bundle savedinstancestate) *
    void Onattach (activity activity) *
    void Onconfigurationchanged (Configuration newconfig) It is called when the configuration sends changes
    void OnCreate (Bundle savedinstancestate) *
    View Oncreateview (Layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) *
    void OnDestroy () *
    void Ondestroyview () *
    void Ondetach () *
    void OnPause () *
    void Onresume () *
    void Onsaveinstancestate (Bundle outstate) *
    void OnStart () *
    void OnStop () *
    void onviewcreated (view view, Bundle savedinstancestate) *
    void Onviewstaterestored (Bundle savedinstancestate) *
  • Use of Mapfragment

    Create activity_fragment.xml :

    <?xml version= "1.0" encoding= "Utf-8"?><linearlayout xmlns:android="Http://schemas.android.com/apk/res/android"  Android:layout_width="Match_parent"android:layout_height="Match_parent"  Android:orientation="vertical">                <framelayoutandroid:id="@+id/fm_map"android:layout_width= "Match_parent" android:layout_height="Match_parent">                        </framelayout></linearlayout>

    To MapFragmentDemo Create a class inheritance baseactivity :

     Public  class mapfragmentdemo extends baseactivity {    PrivateSupportmapfragment map;PrivateFragmentmanager FM;@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (r.layout.activity_fragment);//overlook: Overlooking angle; zoom: ZoomMapstatus ms =NewMapstatus.builder (). Overlook (- -). Zoom ( the). build ();//compassenabled whether to turn on the compass; zoomcontrolsenabled: whether proportional scaling;Baidumapoptions bo =NewBaidumapoptions (). Mapstatus (ms). Compassenabled (false). zoomcontrolsenabled (false);        Map = Supportmapfragment.newinstance (bo);        fm = Getsupportfragmentmanager (); Fm.begintransaction (). Add (R.id.fm_map, Map,"Map_fragemnt"). commit (); }}

    Run:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android intermediate Baidu Map SDK V3.5.0-fragmentmap map Frame [graphic supportmapfragment class]

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.