Vous êtes sur la page 1sur 13

1.

Google Maps
1.1 MapsView
1.2 MapFragment
1.3. Markers
1.4. Changing the GoogleView
1.5. Android emulator and Google Maps
2. Install Google Play services
3. Getting the Google Map key
3.1. Overview
3.2. Creating the SHA-1 for your signature key
3.3. Register with the Google APIs Console
3.4. Create key for your application
4. Tutorial: Google Maps
4.1. Create Project
4.2. Adjust layout file
4.3. Activity
4.4. Run and Test

Create a project with more than 3.0 version API


Open Android Manifest file
Copy <meta-data> Tag from google api link
https://developers.google.com/maps/docum
entation/android/start#installing_the_google_
maps_android_v2_api
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key"/>

paste between <application> Tag

Copy <permission> <user permission >Tag from


google api link
https://developers.google.com/maps/documentation
/android/start#installing_the_google_maps_android_
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
v2_api
android:protectionLevel="signature"/>
<uses-permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVIC
ES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>

Besides permissions required by other parts of your application, you


must add the following permissions in order to use the Google Maps
Android API:
android.permission.INTERNET Used by the API to download map tiles from
Google Maps servers.
android.permission.ACCESS_NETWORK_STATE Allows the API to check
the connection status in order to determine whether data can be
downloaded.
com.google.android.providers.gsf.permission.READ_GSERVICES Allows the
API to access Google web-based services.
android.permission.WRITE_EXTERNAL_STORAGE Allows the API to cache
map tile data in the device's external storage area.

The following permissions are recommended, but can be ignored if your


application does not access the user's current location, either
programmatically, or by enabling the My Location layer.
android.permission.ACCESS_COARSE_LOCATION Allows the API to use
WiFi or mobile cell data (or both) to determine the device's location.
android.permission.ACCESS_FINE_LOCATION Allows the API to use the
Global Positioning System (GPS) to determine the device's location to
within a very small area.

Because version 2 of the Google Maps Android


API requires OpenGL ES version 2, you must add
a <uses-feature> element as a child of
the<manifest> element in AndroidManifest.xml:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

In particular, it has the effect of preventing Google


Play Store from displaying your app on devices
that don't support OpenGL ES version 2.
<uses-feature> Tag Paste in android manifest file

In main.xml, add the following fragment.

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>

So open Eclipse IDE


Help> instal new software
http://keytool.sourceforge.net/update
Copy this above link and paste it in the dialog box
Check the keytool and click next >next .
Accept the aggrement and then click finish.

Open your google api console account.


https://code.google.com/apis/console/
Sign with your account.
After signing in the right side select service
And switch on Google Maps android api v2 = ON
Again select API ACCESS in the down click
[create new android key]
You will get a dialog box to write you SHA1 KEY
and package name.

For SHA1 fingerprint key got to the


eclipse.And open keytool menu> open
keystore and click.
Now you will get a dialog box and there
browse up to debug .keystore in your system
and write password android then load.
Copy the SHA1 finger print from the eclipse
and copy in the google api console account
with the project package name.
79:C2:19:25:3A:96:7C:49:88:46:9F:18:14:78:D8:C4
:09:B5:74:90;com.example.mapdemoproject

Key for Android apps (with certificates)

API key:

AIzaSyBkHSorbwkcSIfT8ulq7Ks0t
D60Wu-5cAQ

Android apps:

79:C2:19:25:3A:96:7C:49:88:46
:9F:18:14:78:D8:C4:09:B5:74:9
0;com.example.mapdemoproject

Activated on:

May 23, 2013 7:34 AM

Activated by:

gouroju.sunil@gmail.com you

API
key:AIzaSyBkHSorbwkcSIfT8ulq7Ks0tD60Wu5cAQ
now paste this api key in your Manifest file in
<meta-data > Tag android Value element. <metadata
android:name="com.google.android.maps.v2.API_KE
Y"
android:value="AIzaSyBkHSorbwkcSIfT8ulq7Ks0tD
60Wu-5cAQ"/>
paste this api key.

public class MainActivity extends FragmentActivity {


private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMap = ((SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();

Here we can Run this only on Real device.


This map view cannot be seen in the emulator.

So this is the way how we Develop Google


Android Maps v2 version.

Vous aimerez peut-être aussi