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.
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.