Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations

Presentation on theme: "Location based services Using Google Maps v2 etc. in Android apps 1Location based services."— Presentation transcript:

1 Location based services Using Google Maps v2 etc. in Android apps 1Location 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 2Location based services

3 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 … 3Location based services

4 Google Maps API versions Google Maps Android API – MapActivity, Overlay, etc. – Deprecated Google Maps Android API v2 – MapFragment, etc. – oid/ oid/ Google Maps for JavaScript v2 – Deprecated Google Maps for JavaScript v3 – script/ script/ Location based services4

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 5Location based services

6 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 services6

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 – aps/article.html#installmaps aps/article.html#installmaps Android Studio can create a special Map activity – This is quite helpful Location based services7

8 How to make it work … when running Google Maps API key – SHA1 + applications package name gives you a key aps_key aps_key – The key must be placed in AndroidManifest.xml Permissions to use Internet, etc. – Stated in AndroidManifest.xml Google Maps requires Open GL – Stated in AndroidManifest.xml 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 services8

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 – Location based services9

10 Getting location updates locationManager.requestLocationUpdates( … ) on/LocationManager.html on/LocationManager.html Example: Maps3 Location based services10

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.html Location based services11

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

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

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

Similar presentations

Ads by Google