Location and Maps
description
Transcript of Location and Maps
![Page 1: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/1.jpg)
Location and Maps 19.3.2013
![Page 2: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/2.jpg)
ContentGetting Location Getting Google Map In applicationTest on Emulator/Device
![Page 3: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/3.jpg)
Getting Location
![Page 4: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/4.jpg)
Location Manager,Location Listener
Get Location providers GPS & Network
Is Better Location?(New, old)
Update location Listener after some interval
Location listener
New location
Is GPS Provider?
Location withGreen Background
Location with Yellow Background
Yes
Display Current Location
No
Use old location
Yes
No
Getting Location
![Page 5: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/5.jpg)
Location Manager,Location Listener
Get Location providers GPS & Network
Update location Listener after some interval
Location listener
Getting Location
The LocationManager provides access to the system location services
On Location change, LocationListener is used for receiving notifications from the Location Manager
![Page 6: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/6.jpg)
Location Manager
![Page 7: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/7.jpg)
Location Listener
MyLocationListener class implements LocationListener LocationListener implements events:
.onLocationChanged ( Location Update ).onProviderDisabled ( GPS Off ).onProviderEnabled (GPS On )
![Page 8: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/8.jpg)
On Location Update
onProviderDisabled (GPS Off)
onProviderEnabled (GPS On)
![Page 9: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/9.jpg)
Modify the AndroidManifest.xml File
Enter the following lines before the application tag:
![Page 10: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/10.jpg)
Is Better Location?(New, old)
New location
Is GPS Provider?
Location withGreen Background
Location with Yellow Background
Yes
Display Current Location
No
Use old location
Yes
No
Getting Location
![Page 11: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/11.jpg)
Current Location
Network:
GPS:
![Page 12: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/12.jpg)
Selecting locationold but accurate or new but inaccurate?
Oldlocation
Newlocation
Accuracy
![Page 13: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/13.jpg)
Google MapGoogle API as the project build
targetMap API Key in order to be deployed
![Page 14: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/14.jpg)
Add Google API in Eclipsehttp://developer.android.com/sdk/adding-components.html
![Page 15: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/15.jpg)
Add Google API in Eclipse
• Use API 4 for SDK 1.6http://developer.android.com/guide/appendix/api-
levels.html
![Page 16: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/16.jpg)
Add Google API in Eclipse
• Set Google API as the Project Build Target– Right-click on the project, select Properties
![Page 17: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/17.jpg)
Get Google Map API Key
Use following link get Google map API
key:http://mobiforge.com/developing/story/using-google-maps-android
![Page 18: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/18.jpg)
Add API key in MapLayout .xml file
API KEY
![Page 19: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/19.jpg)
Map Services
Provided by an external library:– Include the com.google.android.maps package.
Modify the AndroidManifest.xml:
![Page 20: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/20.jpg)
Map Activity and Map View
Map Activity– Maps API add-on provides a Map
Activity class– Helps managing the Map functions using
Map View Map View– Basic functionality of map controller– Zooming and panning
![Page 21: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/21.jpg)
Display mapControl map
Map Activity And Map view
Control map by programProvides map functionality
![Page 22: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/22.jpg)
Provides map functionality
Display map
Animate map to given location
Map Activity And Map view
Control map by program
Generate geo points using latitude and longitude
![Page 23: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/23.jpg)
Example
![Page 24: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/24.jpg)
Test on emulator
To test in Eclipse:→ Switch to DDMS view.→ Find the location controls in the
Emulator Control tab.→ Click the GPX tab and click Load
GPX.→ Locate and select the GPX file.→ Click Play to begin sending
coordinates to the Emulator.
![Page 25: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/25.jpg)
Test on emulator
![Page 26: Location and Maps](https://reader036.fdocuments.in/reader036/viewer/2022070501/5681693e550346895de0bc2f/html5/thumbnails/26.jpg)
Questions?