|The Splash Screen|
There were initial hitches to setup the project. But, once the first steps were done, it was quite easy to build up a simple app.
I want to list down the first steps of the process, and then move on to the sample application.
Step 1: Getting the API key.
- Go to Google API Console
- Go to Services link, and enable Google Maps Android API v2. (Don't confuse this with Google Maps API v2. I got confused, and was wondering what was I doing wrong when the maps failed to load)
- After enabling the service, go to the API Access link.
- In the Simple API access section, click on "Create New Android Key".
- Enter your keystore's SHA1 fingerprint along with your application's package name separated by a semi-colon in the dialog and click on "Save".
- Your API should be visible now on the same page.
Step 2: Setting up the project.
- You need to find the library project for the Google Maps API v2. It should be available in your SDK directory. If not, open up the Android SDK manager and download the same by selecting Google Play Services in the Extras section.
- You would find the required library project in the following location of the SDK folder. (..\android-sdks\extras\google\google_play_services\libproject)
- My suggestion would be to make a copy of this project somewhere else, and then import the project into eclipse.
- Once imported into Eclipse, use this as a library project for your application.
Step 3: Setting up the manifest file.
- Your manifest file should look like this. AndroidManifest.xml
- You can change the package names for the permissions to use your own package name.
- Now, replace your API key with the place-holder API Key in the manifest.
Step 4: MapFragment and more code...
- To show a map, I used the MapFragment in the activity's layout.
That's it. These are the broad steps to configure the new version of Google Maps for your Android application.
|Add a new place|
What this application does?
- On opening the application, you would see a splash screen, and it would try to get your current location.
- Once it gets your location, it would switch to the map view, and display your current location with a marker.
- Tapping on an unmarked area of the app, you would see a dialog, through which you can add a new place.
- After saving the new place by providing a name and a description, this place would be saved into the database and you would be able to see the newly added place on the map.
- Tapping on an already visible marker will show you the details of that place.
- The next time you open the application, all the previously stored places would appear on the map along with your current location.
- While loading the points from the database, it would be nice if we can only load the places which are within the currently visible area of your app.
- When the map is re-sized or moved, we could re-query the database for the fresh list of places and update the markers based on the new visible area.
- The VisibleRegion API, currently, doesn't work. Need to think of a workaround for this.