Saturday, September 28, 2013

Notes for Android Google Maps API Version 2

Some notes:

  • It is required to obtain an API key at the Google APIs console
    • First step is to create a project, the name is not important
    • Within the project, switch on the Google Maps API
    • Create a "Registered App" for each key you want to create
      • I have 1 desktop and 1 notebook, so I ended up registering 2 apps with the debug keys on each machine
      • These keys, by default can be used across apps
  • There are 2 main ways to include a map in a screen
    • The preferred way is to use a fragment, which can be used with the most flexibility with the newer API levels
      • Some older devices won't be able to use fragments unless it's called from within a FragmentActivity
    • Alternatively, MapView can be used but requires life-cycle events to be forwarded to the MapView
  • Gotchas:
    • You have to include the source codes of the Google Play Services library project in your workspace in order to use the API
    • It still doesn't support the ingestion of a KML file and automatically drawing the contents on the map
    • The docs say you don't have to use MapsInitializer.initialize, I've had to do it (with MapView)
Resources:

No comments:

Post a Comment