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 Address II.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 – ion/android/mapkey 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 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 google-maps-longitude-latitude-calculation-question 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 )now,you have particular GEO POINT Location. if you have location like : Latitude: and Longitude: ° So, your GeoPoint( , ); float lat = f; float lng = f; 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.