Before use
Google Maps bring great convenience to people's lives. For example, Google maps can be used to search for merchant information, view maps, and obtain vehicle routes. The Android platform also provides a map package (COM. Google. Android. Maps), where mapview allows you to conveniently program using Google map resources. Make the following necessary settings before use.
(1) Add maps. jar to the Project
In the android SDK, map-related APIs are provided in the form of a jar library, which is in the directory of "Android-SDK-Windows \ add-ons \ google_apis-4. To add maps. jar to a project, you can specify the target containing Google API in the "android" column of the Project attribute as the project building target.
(2) embedding a map into an application
By using the mapactivity and mapview controls, you can easily embed a map into an application. In this step, you need to add the Google API to the build path. Select "Java build path" on the page shown in Figure 12-4, select Google API in target, and set the project to contain Google API
(3) obtain the map API key
Before using mapview, you must apply for an android map API key as follows.
Step 2: Find Your Debug. keystore file, which is usually located in the following directory.
C: \ Documents and Settings \ your current user \ Local Settings \ Application Data \ android
Step 2: Obtain the MD5 fingerprint. Run cmd.exe and run the following command to obtain the MD5 fingerprint.
> Keytool-list-alias androiddebugkey-keystore "Debug. keystore path"-storepass Android-keypass android
For example, enter the following command.
Keytool-list-alias androiddebugkey-keystore "C: \ Documents and Settings \ Administrator \. Android \ Debug. keystore"-storepass Android-keypass android
At this time, the system will prompt you to enter the keystore password, and then enter Android, the system will output the Requested MD5 authentication fingerprint
Step 2: apply for the API key of Android map.
Open your browser and enter the URL: http://code.google.com/intl/zh-cn/ Android/maps-API-signup. html
On the Google Android map API key application page, enter the MD5 fingerprint obtained in Figure 12-6 and press the "generate API key" button to go to the following figure, obtain the applied API key
At this point, an API key is obtained successfully, and the entire preparation before programming is completed.