Google Maps in Android

  • View
    9.667

  • Download
    4

Embed Size (px)

DESCRIPTION

Slides from the workshop presentation at Mobile 2.0 Europe Developer Conference 2010 on "Google Maps in Android" by Israel Ferrer from And.roid.es.

Text of Google Maps in Android

  • 1.Social network
    • Twitter Hashtag: #m2eu #android
  • Personal twitter: @rallat

Israel Ferrer - @rallat israel@bubiloop.com 2. Who am I?

  • Israel Ferrer Camacho
    • co-founderand.roid.es&bubiloop.com
    • Business Developer atbubiloop.com
    • Android Developer
      • Trovit homes:http://bblp.to/10rN
      • and.roid.es news: http://bblp.to/11E6
      • Rac1:http://bblp.to/10uh
      • Bubiloop recommender:http://bblp.to/11Hg
      • Working on salir.com app

Israel Ferrer - @rallat israel@bubiloop.com 3. And.roid.es 10/08 Israel Ferrer - @rallat - israel@bubiloop.com 4. And.roid.es meetup 06/09 Israel Ferrer - @rallat - israel@bubiloop.com 5. Campus Party 08/09 Israel Ferrer - @rallat - israel@bubiloop.com 6. Android workshops 09/10 Israel Ferrer - @rallat israel@bubiloop.com 7. Bubiloop 10/09 Israel Ferrer - @rallat israel@bubiloop.com 8. Androides Barcelona 2010

  • Co-founder of Barcelona Android dev group

Israel Ferrer - @rallat israel@bubiloop.com 9. Mobile Cocktail 02/10Israel Ferrer - @rallat israel@bubiloop.com 10. Google I/O 2010 Israel Ferrer - @rallat israel@bubiloop.com 11. Location and Maps in Android

  • Israel Ferrer Camacho
  • June 17, 2010

Israel Ferrer - @rallat israel@bubiloop.com 12. developer.android.com Israel Ferrer - @rallat israel@bubiloop.com 13. Agenda

  • Google Maps in Android
  • Location in Android
  • Show me the code
  • Questions

Israel Ferrer - @rallat israel@bubiloop.com 14. Google Maps in Android

    • Google Maps is an external library to the Android SDK.

Israel Ferrer - @rallat israel@bubiloop.com Features Google Maps Google Maps Android World Maps Mode Sat/Street View/Traffic Places content Compass 15. Google Maps in Android

  • GeoPoint:longitude/latitude stored as integer in microdegrees (degrees * 1E6)
  • Overlay:Base class representing an overlay which may be displayed on top of a map
  • OverlayItem:The basic component of any ItemizedOverlay.
  • ItemizedOverlay : A base class for an Overlay which consists of a list of OverlayItems

Israel Ferrer - @rallat israel@bubiloop.com 16. Google Maps in Android

  • MapActivity:Base class with code to manage the boring necessities of any activity that displays a MapView
  • MapView:A View which displays a map (with data obtained from the Google Maps service).
  • MapController:A utility class to manage panning and zooming of a map.
  • MyLocationOverlay:An Overlay for drawing the user's current location (and accuracy) on the map, and/or a compass-rose inset.

Israel Ferrer - @rallat israel@bubiloop.com 17. Google Maps in Android

    • What?
      • We can show custom markers with info at someplace in a map
    • How?
      • Prerequisites
      • Show the map using MapView
      • Create our custom marker class
      • MapActivity:
        • Add marker to our located overlays
        • Add this located overlays to our MapView

Israel Ferrer - @rallat israel@bubiloop.com 18. Prerequisites

  • Create an Android project with Google APIs support

Israel Ferrer - @rallat israel@bubiloop.com 19. Prerequisites

  • Manifest Permissions:
    • Add permission to use Google Maps external library
    • Add permission to use Internet
  • Google Maps API key for mobile:
    • http://tinyurl.com/androidkeyapi

Israel Ferrer - @rallat israel@bubiloop.com 20. MapView

  • XML Definition MapView

Israel Ferrer - @rallat israel@bubiloop.com 21. MapActivity

  • Create MapActivity to show the MapView

Israel Ferrer - @rallat israel@bubiloop.com 22. MyLocationOverlay

  • This object create an overlay that shows your location.

23. Custom Marker

  • Object that extends ItemizedOverlay
  • Object is initialize with a Drawable our custom marker

24. Custom Marker

  • Populate our custom marker ItemizedOverlay with OverlayItems
  • Finally, add our custom marker Overlay to MapView Overlays

25. Hello Map! Israel Ferrer - @rallat israel@bubiloop.com 26. To Sum Up Israel Ferrer - @rallat israel@bubiloop.com 27. Location in Android

    • What?
      • Location-based services are technique to figure out where you are
    • How?
      • Prerequisites
      • Location Manager
      • Location Listener

Israel Ferrer - @rallat israel@bubiloop.com 28. Prerequisites

  • Manifest Permissions
    • GPS Location
    • Network Location

Israel Ferrer - @rallat israel@bubiloop.com 29. Location Manager

  • Location-Based Services (LBS) are handle using the LocationManager
  • Two Location providers in Android: GPS, Network
  • Define Criteria object to obtain the best provider

Israel Ferrer - @rallat israel@bubiloop.com 30. Location Manager

  • One we get the best provider is time to get location
    • Get last know location
    • Get the location changes
      • Request Location Manager this updates

Israel Ferrer - @rallat israel@bubiloop.com 31. Location Listener

      • Used for receiving notifications from the LocationManager when the location has changed

Israel Ferrer - @rallat israel@bubiloop.com 32. To Sum Up Israel Ferrer - @rallat israel@bubiloop.com 33. Maps and Location

  • Easy to use in your apps
  • Once weve got the location, we can show data on the map just with the method update(location) to refresh de UI

Israel Ferrer - @rallat israel@bubiloop.com 34. Q&A

  • All the source from this session is in
  • http://bblp.to/mobile20
  • Questions?

Israel Ferrer - @rallat israel@bubiloop.com 35. Thanks

  • Twitter:@rallat
  • Mail:israel@bubiloop.com
  • Projects:bubiloop.com & and.roid.es

Israel Ferrer - @rallat - israel@bubiloop.com