Using Location and Map APIs
What and why•Use Maps to display locations•GPS to sense current location (LocationManger class in Android)s•Geocoding = translation from and to addresses and latitude, longitude
GOOGLE Maps in transition•There is a v1 and v2 Google Maps API.•Use the later version •Warning depending on version of emulator –it may not support v2 yet –test on device
Incorporating Android Location APIs•The Android location APIs are built directly into the Android SDK.•Until Google Play services introduced the new Google Location Services APIs, the android.locationpackage provided the sole means for working with the location features of a device.•Even though the new Google location APIs are much more robust, here are some reasons why you should care about the Android location APIs:–Not all devices are capable of having Google Play services installed.•Therefore, it is impossible to access the Google location APIs on these devices.–There are many classes available in the Android location APIs that are not available in the Google location APIs.•This means that you are able to make use of the best of both APIs (provided they are both available), rather than relying on one over the other.
Google Maps API v2
Google Maps Android API v2•Part of the Google Play services SDK, •Use MapFragmentclass•Version 2 uses vector tiles. Their data representation is smaller, so maps appear in your apps faster, and use less bandwidth. –For more: check Mapbox•Caching is improved, so users will typically see a map without empty areas. •Maps are now 3D. You can change user perspective
PROBLEM: v2 is not supported on some Android Emulator •Generally best to have a physical device to test.•ALSO: devices not supporting OpenGL ES2.0 won't be able to run apps with maps (older devices)
Adding Map to Project1.Download and configure the Google Play servicesSDK. The Google Maps Android API is distributed as part of this SDK. 2.Obtain an API key. To do this, you will need to register a project in the Google APIs Console, and get a signing certificate for your app.3.Setup your Project to say it is using the GooglePlay Services4.Specify settingsin the Application Manifest. Add a map to a new or existing Android project.
App must ask for permissions•In AndroidManifest.xml file (right after <manifest tag):<uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><!-- The following two permissions are not required to useGoogle Maps Android API v2, but are recommended. --><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Specify Use of OpenGL•The Google Maps Android API uses OpenGL ES version 2 to render the map. If OpenGL ES version 2 is not installed, your map will not appear.
You've reached the end of your free preview.
Want to read all 68 pages?
- Fall '12
- Google Maps, android location apis