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 Proximity sensor Not really location based … Many devices can “feel” if an object is near the device. Proximity sensor – Example: ProximityExample Devices usually have many other censors Location based services2

3 Where am I? Obtaining the device’ location LocationManager class Listen for changes in the location Example – LocationManagerExample Location based services3

4 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 services4

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

6 Google Maps API versions Google Maps Android API – MapActivity, Overlay, etc. – Deprecated Google Maps Android API v2 – https://developers.google.com/maps/documentation/ android/ https://developers.google.com/maps/documentation/ android/ Google Maps for JavaScript v2 – Deprecated Google Maps for JavaScript v3 – https://developers.google.com/maps/documentation /javascript/ https://developers.google.com/maps/documentation /javascript/ Location based services6

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

8 Some Map related classes Example: Map5 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_FINE_LOCATION UISettings – To change the default settings of the map 8Location based services

9 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 services9

10 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 – http://www.vogella.com/articles/AndroidGoogleM aps/article.html#installmaps http://www.vogella.com/articles/AndroidGoogleM aps/article.html#installmaps Android Studio can create a special Map activity – This is quite helpful Location based services10

11 How to make it work … when running Google Maps API key – SHA1 + applications package name gives you a key http://www.vogella.com/articles/AndroidGoogleMaps/article.html#m aps_key http://www.vogella.com/articles/AndroidGoogleMaps/article.html#m 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 services11

12 Getting location updates locationManager.requestLocationUpdates( … ) http://developer.android.com/reference/android/locati on/LocationManager.html http://developer.android.com/reference/android/locati on/LocationManager.html Example: Maps5 Location based services12

13 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 – http://developer.android.com/guide/topics/location/obtaining-user- location.html Location based services13

14 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 services14

15 References and further readings Google Maps Android API v2 – https://developers.google.com/maps/documentation/android/ https://developers.google.com/maps/documentation/android/ Lars Vogel: Google Maps Android API v2 – Tutorial – http://www.vogella.com/articles/AndroidGoogleMaps/article.ht ml http://www.vogella.com/articles/AndroidGoogleMaps/article.ht ml George Mathew: Remove a single marker from Google Maps Android API V2 … – http://www.vogella.com/articles/AndroidGoogleMaps/article.ht ml http://www.vogella.com/articles/AndroidGoogleMaps/article.ht ml Making your app location-aware – http://developer.android.com/training/location/index.html http://developer.android.com/training/location/index.html Location based services15


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

Similar presentations


Ads by Google