New usage of Android Map: introduction to MapFragment application

  • 2020-05-07 20:26:31
  • OfStack

The limitation of this is that you must inherit MapActivity or you cannot use MapView. That's the struggle. However, the latest official website has abandoned this dregs of 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. The limitation of MapFragment is that you must install Google Play Service, which means it must be native rom. And sdk should be above 12. I'm in pain.

3.WebView seems easy to integrate, but without practice, it has no say.
I'm going to skip the first one. Everybody knows that. Say the second one, the third one and make up for it
MapFragment is the official google package that just came out, so it's a bit of a hassle to integrate. Website links https: / / developers. google. com maps/documentation/android/start
First, go to google conlose to add api access permission, get apikey, create an project, then go to services and open Google Maps Android API v2, then go to api access and fill in your project keystore SHA1 and package name, get api key only
Open sdk manager - in the Extras Android Support Libaray and Google Play Services installation, lib and samples sdk_path/extra/google/google_play_services. Import.. /lib_project as libaray for your own project
After this step, add permissions and api key in the manifest.xml file. The following code
 
<permission 
android:name="com.example.permission.MAPS_RECEIVE" 
android:protectionLevel="signature"/> 

com.example is replaced by package of its own project
 
<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"/> 

It's in the application statement
 
<meta-data 
android:name="com.google.android.maps.v2.API_KEY" 
android:value="appkey"/> 

Add MapFragment declarations to layout xml
 
<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"/> 

activity is the same, extends Activity is fine. There is no need to inherit MapActivity.
Note that the debug state is not allowed to display the map, 1 must be the official signature of map will be displayed.
You should see map under install

And do not understand the official document to see more, the introduction is very clear. The above is just for my own memory.

Related articles: