Using Google Maps

Google maps can be used on the Android system in two ways: user access through a browser and application access through the Google Maps Application Programming Interface (API).The MapView class is a wrapper around the Google Maps API.To use MapView, the following setup is needed:

1. Download and install the Google API's Software Development Kit (SDK):

1. Use the Android SDK and Android Virtual Device (AVD) manager in Eclipse to download the Google API.

2. Right-click the project that uses the API, and then select Properties.

3. Select Android, and then select Google API to enable it for this project.

2. Obtain a valid Maps API key to use the Google Maps service (see http://code. google.com/android/add-ons/google-apis/mapkey.html):

1. Use the keytool command to generate an MD5 certificate fingerprint for the key alias_name:

> keytool -list -alias alias_name -keystore my.keystore

> result:(Certificate fingerprint (MD5):

2. Use the MD5 keystore to sign up for the Google Maps service at http://code.google.com/android/maps-api-signup.html.

3. A Maps API key is provided upon signup. Use this key with MapView.

3. Include <uses-library android:name="com.google.android.maps" /> in the AndroidManifest.xml file to inform the Android system that the application uses the com.google.android.maps library from the Google API's SDK.

4. Add the android.permission.INTERNET permission to the AndroidManifest.xml file so the application is allowed to use the Internet to receive data from the Google Maps service.

5. Include a MapView in the layout XML file.

More specifically, the two supporting files needed for a Google Maps activity are as follows. First, the AndroidManifest XML file needs the proper maps library and permissions, as shown in Listing 10.8.

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook


Post a comment