• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Google Maps API for Android

  • 16,098 views
Uploaded on

Presenting use of Maps, distance calculation, geolocation. …

Presenting use of Maps, distance calculation, geolocation.

Code examples.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
16,098
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
410
Comments
0
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Maps API Brief introduction Maksim Golivkin www.androidaalto.org www.mobileguild.eu Twitter: MaksimGolivkin 13.11.2010 Android Aalto Community
  • 2. Plan Intro to Google Maps API MapView & MapActivity Overlays Distances Balloons Geocoding UI update with handlers 13.11.2010 Android Aalto Community
  • 3. Intro to maps API: New Project Target build and emulator have to use Google API for platform you have chosen. For instance, Google API for 1.6 13.11.2010 Android Aalto Community
  • 4. Intro to maps API : AndroidManifest.xml Things to remember: uses-library declaration for runtime permissions to access Internet, GPS and network location. 13.11.2010 Android Aalto Community
  • 5. MapView: Layout If you use inappropriate API key, map won't be displayed. For one Google account you can generate several keys. How to generate your own key: http://code.google.com/android/add-ons/google-apis/mapkey.html 13.11.2010 Android Aalto Community
  • 6. MapActivity onCreate 13.11.2010 Android Aalto Community
  • 7. Overlays Each overlay is information layer on the map. Google Maps provides 3 overlay classes: Overlay - drawing complex figures on the map and capturing touch moves. ItemizedOverlay - abstract, extends Overlay, for drawing of multiple markers. MyLocationOverlay - drawing user location. 13.11.2010 Android Aalto Community
  • 8. Overlays: hierarchy 13.11.2010 Android Aalto Community
  • 9. Overlays: ItemizedOverlay #1 Most important thing: on every content change ItemizedOverlay, call protected populate method; include populate call in contructor Reference: http://code.google.com/p/android/issues/detail?id=2035 13.11.2010 Android Aalto Community
  • 10. Overlays: ItemizedOverlay #2 13.11.2010 Android Aalto Community
  • 11. Overlays: ItemizedOverlay usage 13.11.2010 Android Aalto Community
  • 12. Overlays: MyLocationOverlay Convenient to display user location on map. Most important thing: call disableMyLocation, when activity goes to background. 13.11.2010 Android Aalto Community
  • 13. Overlays: MyLocationOverlay usage 13.11.2010 Android Aalto Community
  • 14. Distance Note: Google Maps API uses (int) micro-degrees for coordinates; Android Location package uses (double) degrees for coordinates; microdegrees = degrees * 1000 000; or microdegrees = degress * 1E6; degrees = microdegrees / (double)1E6; 13.11.2010 Android Aalto Community
  • 15. Distance calculation 13.11.2010 Android Aalto Community
  • 16. Balloons : usage 13.11.2010 Android Aalto Community
  • 17. Balloons Nice small existing library. Available at: https://github.com/jgilfelt/android- mapviewballoons 13.11.2010 Android Aalto Community
  • 18. Geocoding Geocoding - translating coordinates to address. Reverse geocoding - translating address from coordinates. GeoCoder class. Use GeoCoder in background thread! 13.11.2010 Android Aalto Community
  • 19. UI update with Handler Nested anonymous classes are ugly! Alternative: Handler + Message + Bundle. Note: when updating UI, be sure to instantiate in UI thread. E.x. onCreate method. 13.11.2010 Android Aalto Community
  • 20. Example code can be found at: http://mobileguild.eu/FindHackatron.zip Thank you! 13.11.2010 Android Aalto Community