Android Map New usage: Introduction to mapfragment Application _android

Source: Internet
Author: User
1.MapView, mapactivity This limitation is that you must inherit mapactivity, otherwise you cannot use Mapview. This is where the tangle lies. However, the latest official online has abandoned the dross of the mapactivity.

Version 1 of the Google Maps Android API as been officially deprecated as of December 3rd, 2012. This means is March 3rd, 2013 you no longer is able to request a API key for this version. No new features is added to Google Maps Android API v1. However, apps using v1 would continue to work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.

2.MapFragment This limitation is that you must install the Google Play Service, which means that you must be a native ROM. And the SDK needs to be above 12. My eggs are hurting.

3.WebView seems very easy to integrate in, but no practice on the wood has a say.
The first way I skipped it first. We all know that. Say the second, the third will be made up.
Mapfragment is just out of Google's official package, to integrate in or very troublesome. Website Link Https://developers.google.com/maps/documentation/android/start
First go to Google conlose Add API access permissions, get Apikey, create a project, and then go to services to open the Google Maps Android API v2 to the API In Access, fill in your project's KeyStore SHA1 and package name, and get the only API key
Open SDK manager--install android Support Libaray and Google play services in extras, both Lib and samples are in Sdk_path/extra/google/google_ Play_services under. Import.. /lib_project as the libaray of his own project
After this step, add permissions and API key to the Manifest.xml file. The code is as follows
Copy Code code as follows:

<permission
Android:name= "Com.example.permission.MAPS_RECEIVE"
Android:protectionlevel= "Signature"/>

Com.example replaces the package of your project
Copy Code code as follows:

<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 es2.0.-->
<uses-feature
android:glesversion= "0x00020000"
Android:required= "true"/>

Put it in the application statement.
Copy Code code as follows:

<meta-data
Android:name= "Com.google.android.maps.v2.API_KEY"
Android:value= "Appkey"/>

Adding mapfragment declarations in Layout xml
Copy Code code as follows:

<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 activity does not change, extends activity is OK. No need to inherit mapactivity.
Note that the debug state is not able to display the map, it must be in the official signature map will be displayed.
Install should be able to see the map.

There are not understand the more to see the official document, the introduction is very clear. The above is only convenient for my own memory.
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.