Presentation is loading. Please wait.

Presentation is loading. Please wait.

Location based services

Similar presentations


Presentation on theme: "Location based services"— Presentation transcript:

1 Location based services
Using Google Maps v2 etc. in Android apps Location based services

2 Some location-based services available in Android
Google maps Showing and annotating maps Geo-coding Address -> location Reverse geo-coding Location -> address(es) Getting live location information Through GPS, mobile phone cell tower triangulation, or Wi-Fi positioning Location based services

3 Location based services
Google maps Google maps are NOT part of the Android API It’s an add-on This means that you will have to do a number of things to make it work … Location based services

4 Google Maps API versions
Google Maps Android API MapActivity, Overlay, etc. Deprecated Google Maps Android API v2 MapFragment, etc. Google Maps for JavaScript v2 Google Maps for JavaScript v3 Location based services

5 Some Map related classes
Example: maps2013 GoogleMap This is the main class setOnMapClickListener(…) Hitting the map you can add markers, etc. MyLocation Will send you to your current location Requires permissions: ACCESS_COARSE_LOCATION and ACCESS_FINEL_LOCATION UISettings To change the default settings of the map MapFragment To show the map as part of an activity Not used in the layout.xml (only “fragment”) Used in the Activity (Java code) Android ≥ 3 (API 11) only SuppportMapFragment for older devices MapView Another way to show a map Location based services

6 Location based services
Markers Marker An annotation on a map Map. setOnMarkerClickListener(…) Event when you hit a marker MarkerOptions The “constructor” parameters for Marker objects Position, title, icon, etc. Circle, and other annotation You can add circles (and many other annotation) to a map Location based services

7 How to make it work … when programming
Google Maps API v2 is part of Google Play services SDK Use the Android SDK Manager to obtain the ”Google Play Services” API It’s in “Extra” at the bottom of the screen Android Studio can create a special Map activity This is quite helpful Location based services

8 How to make it work … when running
Google Maps API key SHA1 + applications package name gives you a key The key must be placed in AndroidManifest.xml Permissions to use Internet, etc. Stated in AndroidManifest.xml Google Maps requires Open GL Genymotion: Has no access to GooglePlay It should be possible to upgrade GenyMotion, but I can’t make it work It run the app on my Android phone Location based services

9 Getting location data: Where am I?
Some applications needs to know the current position of the user’s device. Three ways to obtain the position GPS satellite Most accurate Mobile phone cell tower triangulation Works indoors Wi-Fi The address of the connected Wi-Fi should be known Least accurate AndroidManifest.xml <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> Location based services

10 Getting location updates
locationManager.requestLocationUpdates( … ) Example: Maps3 Location based services

11 Different location providers: Pros and cons
GPS_PROVIDER Accurate Works only outdoors Device must have satellite connection Consumes battery Satellite connection consumes battery Slow NETWORK_PROVIDER Less accurate Works indoors (Wi-Fi + cell-tower) and outdoors (cell-tower) Consumes less battery Faster Source Location based services

12 Location based services
Geocoding Getting real addresses from a position GeoCoder List<Address> getFromLocationName(name, howMany) Geocoding Address includes ordinary address + (lat, long) List<Address> getFromLocation(lat, long, howMany) Reverse geocoding Example: Maps3 Location based services

13 References and further readings
Google Maps Android API v2 Lars Vogel: Google Maps Android API v2 – Tutorial George Mathew: Remove a single marker from Google Maps Android API V2 … Making your app location-aware Location based services


Download ppt "Location based services"

Similar presentations


Ads by Google