New Android map usage: mapfragment

Source: Internet
Author: User

1. Limitations of mapview and mapactivity are that mapactivity must be inherited; otherwise, mapview cannot be used. This is the tangle. However, the latest official website has abandoned this bad mapactivity.

Version 1 of the Google Maps Android API as been officially deprecated as of December 3rd, 2012. this means that from March 3rd, 2013 you will no longer be able to request an API key for this version. no new features will be added to Google Maps Android API V1. however, apps using V1 will continue to work on devices. existing and new developers are encouraged to use Google Maps Android API V2.

2. mapfragment: Google Play service must be installed, that is, it must be a native Rom. In addition, the SDK must be at least 12. It hurts me.

3. webview seems to be easily integrated, but it has a say without practice.

 

The first method is skipped. Everyone knows. The second and third types will be supplemented.

Mapfragment is the official Google package. It is quite troublesome to integrate it. Official Website https://developers.google.com/maps/documentation/android/start

    • First, add the API access permission to Google conlose, get the apikey, create a project, and Open google maps Android API v2 in services, enter the keystore sha1 and package name of your project in API access to obtain the Unique API key.
    • Open SDK manager -- install Android support libaray and Google Play services in extras, and install lib and samples in sdk_path/extra/Google/google_play_services. Import ../lib_project as the libaray of your project
    • After completing this step, add the permission and API key to the manifest. xml file.CodeAs follows:
    • 12345678910111213141516171819 < Permission Android : Name = "Com. example. Permission. maps_receive" Android : Protectionlevel = "Signature" / > Com . Example Replace with yourself Project Of Package < Uses - Permission Android : Name = "Com. example. Permission. maps_receive" / > < Uses - Permission Android : Name = "Android. Permission. write_external_storage" / > < Uses - Permission Android : Name = "Android. Permission. Internet" / > < Uses - Permission Android : Name = "Com. Google. Android. providers. GSF. Permission. read_gservices" / > < ! -- My Location -- > < Uses - Permission Android : Name = "Android. Permission. access_coarse_location" / > < Uses - Permission Android : Name = "Android. Permission. access_fine_location" / > < ! -- Maps API Needs OpenGL Es 2.0. -- > < Uses - Feature Android : Glesversion = "0x00020000" Android : Required = "True" / > Put in Application Declaration < Meta - Data Android : Name = "Com. Google. Android. Maps. v2.api _ key" Android : Value = "Appkey" / >

      Add the mapfragment statement to layout XML.

      12345 < Fragment Xmlns : Android = Http://schemas.android.com/apk/res/android" Android : ID = "@ + ID/Map" Android : Layout_width = "Match_parent" Android : Layout_height = "Match_parent" Class = "Com. Google. Android. GMS. Maps. mapfragment" / >

      The extends activity does not change. Mapactivity does not need to be inherited.

       

      Note: The map cannot be displayed in the debug status. The map must be displayed under the formal signature.

      You can see the map under install.

      If you still don't understand it, please read the official documentation to make it clear. The above is just for me to remember.

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.