Open main menu

CDOT Wiki β

Changes

MAP524/DPS924 Lecture 9

1,005 bytes added, 00:08, 6 August 2015
Using Google Maps
* See [https://developers.google.com/android/guides/setup here]. Note it's talking about the build.gradle file inside the app subdirectory of your project.
* You'll need an emulator with the proprietary Google Play libraries installed. Your existing emulator might not have them.
* For Google Maps you'll need a real device, the maps won't work on an Android emulator(with or without Google services on the image).** You can use the free [https://www.genymotion.com GenyMotion emulator] and follow unofficial [https://github.com/codepath/android_guides/wiki/Genymotion-2.0-Emulators-with-Google-Play-support setup instructions] to get google maps to work in that emulator.*** To run GenyMotion on the [[ICT_USB_Sticks]] you'll need to install VirtualBox like so (as root): <code>apt-get install virtualbox-4.3</code>
== Using Google Maps ==
 
=== Obtain API Access ===
There are many guides [https://developers.google.com/maps/documentation/android/intro here].
** In Credentials/Public API access add a new Android key.
** I had to wait a minute for it to show up.
* [https://developers.google.com/maps/documentation/android/signup#add_the_api_key_to_your_application Add that key] to your app.=== Code === 
* If you haven't already done it - follow the "Setup to use Google Play Services" section above.
* [https://developers.google.com/maps/documentation/android/signup#add_the_api_key_to_your_application Add the API key] to your app.
* The rest of the code you can find in parts of [https://developers.google.com/maps/documentation/android/map this tutorial], specifically to get the minimum going you'll need to:
** Add the appropriate fragment XML code to your activity layout and position it so that it doesn't cover other elements in your activity.
** Make your activity implement FragmentActivity.
** Use getMapAsync() to set up your activity to be the callback for when the map loads.
** Do something interesting in onMapReady()