adding location nasrullah. adding location adding a map activity obtaining a map api debug key...

21
Adding Location Nasrullah

Upload: frank-hill

Post on 13-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Adding Location

Nasrullah

Adding Location• Adding a Map Activity• Obtaining a Map API Debug Key• Adding a Map View• Finding an Address with Google’s GeoCoder• Returning the choosen from the map Activity.

Task Manager

I. Find an AddressII. Choose the Address to add a Task

Cast of Characters• MapView- A Google Map ,just like the official Maps

Application

• MapActivity- An Activity that knows how to display the MapView

• GeoCoder- a class that can search for a location,returning an address with latitude and longitude.

Step one- Adding a Location

Add Location Steps

Step 2Map View On the Screen

Obtaining a Google API key• To use Google Map’s API you need an API key• One Production key and many debug keys– One debug key for every developer machine– https://developers.google.com/maps/documentat

ion/android/mapkey

My Debug key

Step 2- Map View Steps

You also requried INTERNET Permission for that app

Step 3-Finding an Address

Geocoder• Returns List<Address>• getFromLocation-search for addresses near

longitude and latitude• getFromLocationName-search for a location

by name• getFromLocationName-search for a location

within a “geofence” –a box defined by longitude and latitude

Finding and Displaying an Address Steps

Step 4

• Returning the address to the AddTaskActivity

Step 4 –Returning an address

Returning an Address Steps

Longitude*1E6

• The reason they are multiplied by 1E6 is because the GeoPoint class (which is used to plot points on a Google Map) uses microdegree latitude and longitude as integers. Multiplying by 1E6 converts degrees into microdegrees. The reason Google chose to do it this way is up to debate, but it probably has to do with the fact that the Google Maps themselves are not extremely accurate, and using a raw double value to 10 or more decimal places returned by the GPS is an unnecessary level of accuracy to plot a point on a Google Map.

• SOURCE http://stackoverflow.com/questions/6125476/android-google-maps-longitude-latitude-calculation-question

GeoPoint

• 1)First you have data(Location) in degree formate. 2)By the Equation you have to multiply it by 1000000 3)now ,you have particular GEO POINT Location .

• if you have location like : Latitude:23.0395677 and Longitude:72.5660045° So, your GeoPoint(23039568,72566045);

• float lat = -23.4456f; float lng = 45.44334f; GeoPoint gp = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));

What we did?

• Added a map Activity• Got a Debug key• Added a MapView• Used GeoCoder to find an Address• Displayed the address returned from the map

activity.