Map Development Instance

Source: Internet
Author: User

1. Google map Introduction
APIS provided by Google to developers
1) map-based API
2) Android encapsulates most map functions in mapview
3) mapview obtains data through the googlemaps service.
And displayed as a map
4) mapview provides a set of controls for map control.
2. Obtain the Maps API key
1) ApplicationProgramSignature (developer of the Identification Program)
The certificate contains a unique key.
2) procedure for applying for a map API key
A. Generate a certificate fingerprint
1. Switch to the. Android directory under cmd
2. Enter the command: keytool-list-alias androiddebugkey-keystore Debug. keystore
3. Prompt: Enter the keystore password: (the password is Android)
4. Obtain the authentication fingerprint: MD5 encrypted string:
88 0: 55: 11: 25: 46: 0f: 03: 21: 14: 74: C1: E6: FB: BB: 3D
5. Open the website: Http://code.google.com/intl/zh-CN/android/maps-api-signup.html
6. On this page, enter the above fingerprint and enter it.
7. Go to Google map to get what you need.
Your key is: 0aghymxi3zvyfk-wg5x4easzhcxnjcrexmbo7zw
This key applies to all applications that use the certificate corresponding to the following fingerprint for verification:
67: A6: E5: 80: AC: B5: 8f: 8e: Be: 37: 1f: Be: 32: 1D: B3: 5b
The following is an XML format example to help you understand the map function:
<Com. Google. Android. Maps. mapview
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: apikey = "0aghymxi3zvzuxjgd7qnmjcj1_fai7mmiqwzp-w"
/>
3. Create the first mapview
Note: When creating a project, select Google APIs for the API
The simulator also chooses Google APIs.
Activity inherits mapactivity.
If the key is written incorrectly, a blank map is displayed.
Layout file (use of the mapview Control ):
<Com. Google. Android. Maps. mapview
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: enabled = "true"
Android: clickable = "true"
Android: apikey = "0aghymxi3zvzuxjgd7qnmjcj1_fai7mmiqwzp-w"
/>
In the main configuration file:
<Application> Add application map permission
<Uses-library Android: Name = "com. Google. Android. Maps"/>
4. map marking
1) Add a flag to the map
Three Layers (mapview overlay1 overlay2)

Procedure:
A. Create a separate layer on mapview
B. Create a tag object
C. The tag is displayed at the specified position of the specified layer.
D. Process click tag events
2) Role of overlay (overlay is an abstract class)
Map-tagged container
3) Role of itemizedoverlay <overlayitem>
A. It is a subclass of overlay.
B. contains one or more overlayitem objects.
C. Each overlayitem represents a tag
4) How to Use itemizedoverlay
5. Drawing path on the map
1) Projection
Geopoint)
Point)
Note: geopoint indicates the start point and end point.
Convert longitude and latitude to XY coordinates on the screen
Method implementation:
A. Longitude and latitude ---> coordinates
Projection. topixels (geopoint, point );
B. Coordinates ---> longitude and latitude
Projection. frompixels (int x, int y)
2) how to draw a straight line on GoogleMap
Steps:
A. Determine the start and end longitude and latitude coordinates of the line
B. Draw icons on the start and end points
C. Convert the longitude and latitude coordinates into the X and Y axes on the screen.
D. Draw a route between the start and end points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.