SlideShare a Scribd company logo
l

Maps
l

l
l

Maps

Google Maps API is widely used on the web
The Android SDK provides support for easily
integrating the Google Maps API
l
l

l

Using Google Maps in our apps

Configure
l Maps require the Google API as the project build
target
l Maps require a Map API Key in order to be
deployed
l http://code.google.com/android/add-ons/googleapis/maps-overview.html
Code
l Create a MapView in a MapActivity
l Create Map Overlays
l

Add Google API in Eclipse

• http://developer.android.com/sdk/adding-components.html
l
l

Add Google API in Eclipse

Use API 4 for SDK 1.6

– http://developer.android.com/guide/appendix/api-levels.html
l
l

Add Google API in Eclipse

Set the Google API as the Project Build Target
l Right-click on the project, select Properties
l

l

•
l

l

Keys

As we learned in lab 1 section 6,

– https://sites.google.com/site/androidappcourse/labs/lab-1

our apps must be signed in order to deploy them
on a device
Eclipse automatically creates a signed debug
keystore that is used when launching our app from
Eclipse
In order to deploy our app to the public, we must
create a signed keystore
– See http://developer.android.com/guide/publishing/appsigning.html#ExportWizard
l

Find your keystore

• http://code.google.com/android/add-ons/googleapis/mapkey.html
l

Find your debug keystore

• http://code.google.com/android/add-ons/googleapis/mapkey.html
l

Get your certificate fingerprint

• http://code.google.com/android/add-ons/googleapis/mapkey.html
l

Register your certificate with Google

• http://code.google.com/android/maps-api-signup.html
l

Add the Map API Key to your
Application

• <com.google.android.maps.MapView
•
android:id="@+id/myMap"
•
android:layout_width="fill_parent"
•
android:layout_height="fill_parent"
•
android:clickable="true"
•
android:apiKey="@string/mapApiKey"/>
l

l

l

What’s in the legal agreement?

Read the Terms of Service (sections 1-11)
l http://code.google.com/android/maps-api-signup.html
Examples
l Maps may include ads in future
l Google may limit number of transactions
l Cannot use for turn-by-turn directions or autonomous driving
l

Configure AndroidManifest.xml

• <application android:name="MyApplication" >
• <uses-library android:name="com.google.android.maps" />
• ...
• </application>
l

l

Finally, we can start coding

MapView
l Contains a map
l via Google Maps API
l Map tile retrieval and caching is all done for
you
l Includes pan
l Includes zoom
l use setBuiltInZoomControls(true);
l

l

MapActivity

MapView can only be constructed or inflated in a
MapActivity

• public class MyActivity extends MapActivity {
•…
• @Override
• public void onCreate(Bundle savedInstanceState) {
•
super.onCreate(savedInstanceState);
•
…
•
MapView myMap = (MapView)findViewById(R.id.myMap);
•
myMap.setBuiltInZoomControls();
•
myMap.setSatellite(true);
l

l

MapView Modes

MapView
l You determine mode
l setSatellite(true);
l setTraffic(true);
l setStreetView(true);
l

l

•
•
•
•
•
•
•

MapController

You can pan and zoom the map programmatically

MapView myMap = (MapView)findViewById(R.id.myMap);
MapController mapController = myMap.getController();
mapController.setZoom(1); //widest zoom/far away
…
mapController.setZoom(21); //narrowest zoom/close in
mapController.zoomIn(); //one level
mapController.zoomOut(); //one level
l

l

GeoPoint

You can move to a particular point

•
•

MapView myMap = (MapView)findViewById(R.id.myMap);
MapController mapController = myMap.getController();

•
•
•
•
•
•

Double lat = 37.123456 * 1E6;
Double long = -122.123456 * 1E6;
GeoPoint point = new GeoPoint(lat.intValue(), long.intValue());
mapController.setCenter(point); //jump to point
…
mapController.animateTo(point); //smooth transition to point
l

l

Reverse Geocoding

Find address from longitude/latitude
•
•
•
•
•
•
•
•
•
•

location = locationManager.getLastKnownLocation(
LocationManager.GPS_PROVIDER);
double lat = location.getLatitude();
double lng = location.getLongitude();
Geocoder gc = new Geocoder(this, Locale.getDefault());
List<Address> addresses = null;
try {
addresses = gc.getFromLocation(lat, lng, 10);
} catch (IOException e) {}
l

l

Forward Geocoding

Find longitude/latitude (and more) from address

•
•
•
•
•
•
•
•

Geocoder gc = new Geocoder(this, Locale.US);
List<Address> addresses = null;
try {
addresses = gc.getFromLocationName(
“123 Main St., Newton, Kansas”, 10);
} catch (IOException e) {}
double lat = addresses.get(0).getLatitude();
String zip = addresses.get(0).getPostalCode();
l

l

Geolocation

Options
l GPS, cell network
l Wifi-based
l Skyhook Wireless
l http://www.skyhookwireless.com/developers/Android_Integration_M
anual.php
l

•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

Setting up location services

public MyActivity() {
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
};
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
updateWithNewLocation(location);
}
public void onProviderDisabled(String provider) {
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

@Override
protected void onStart() {
super.onStart();
locationManager = (LocationManager)getSystemService(
Context.LOCATION_SERVICE);
provider = locationManager.getBestProvider(criteria, true);
// or could be LocationManager.GPS_PROVIDER
try {
updateWithNewLocation(locationManager.getLastKnownLocation(
provider));
} catch (Exception e) {}
locationManager.requestLocationUpdates(provider, 2000, 10,
locationListener);
}
private void updateWithNewLocation(Location location) {
double latitude = 0.0;
double longitude = 0.0;
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
//do something with latitude and longitude (e.g. print or move map there)
}
l

•
•
•
•
•
•
•
•
•

Turn GPS on and off to save battery

@Override
protected void onPause() {
super.onPause();
//stop receiving GPS locationManager.removeUpdates(locationListener);
}
@Override
protected void onResume() {
super.onResume();
//restart receiving GPS locationManager.requestLocationUpdates(provider,
2000, 10,
•
locationListener);
• }

More Related Content

Similar to Map

Augmented Reality on iPhone Applications
Augmented Reality on iPhone ApplicationsAugmented Reality on iPhone Applications
Augmented Reality on iPhone Applications
Omar Cafini
 
Intro To Google Maps
Intro To Google MapsIntro To Google Maps
Intro To Google Maps
Eric ShangKuan
 
@Ionic native/google-maps
@Ionic native/google-maps@Ionic native/google-maps
@Ionic native/google-maps
Masashi Katsumata
 
Android application for gps
Android application for gpsAndroid application for gps
Android application for gps
Sutej Chakka
 
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
jonmarimba
 
Geolocation and Mapping
Geolocation and MappingGeolocation and Mapping
Geolocation and Mapping
Ivano Malavolta
 
Android mobile application for gps
Android mobile application for gpsAndroid mobile application for gps
Android mobile application for gps
Sutej Chakka
 
Processing 2.0 + Open Data
Processing 2.0 + Open DataProcessing 2.0 + Open Data
Processing 2.0 + Open Data
Steven Battle
 
Maps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkokMaps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkok
ss318
 
Sirius Web Advanced : Customize and Extend the Platform
Sirius Web Advanced : Customize and Extend the PlatformSirius Web Advanced : Customize and Extend the Platform
Sirius Web Advanced : Customize and Extend the Platform
Obeo
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
CommonsWare
 
Integrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS AppIntegrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS App
Hitesh Kumar Singh
 
Philipp Nagele (Wikitude): What's Next with Wikitude
Philipp Nagele (Wikitude): What's Next with WikitudePhilipp Nagele (Wikitude): What's Next with Wikitude
Philipp Nagele (Wikitude): What's Next with Wikitude
AugmentedWorldExpo
 
Angular google maps tutorial quick guide
Angular google maps tutorial quick guideAngular google maps tutorial quick guide
Angular google maps tutorial quick guide
Katy Slemon
 
ARCore 101: A Hands-on Workshop
ARCore 101: A Hands-on WorkshopARCore 101: A Hands-on Workshop
ARCore 101: A Hands-on Workshop
Unity Technologies
 
Create Location Sharing apps using the Ionic framework
Create Location Sharing apps using the Ionic framework					Create Location Sharing apps using the Ionic framework
Create Location Sharing apps using the Ionic framework
Shelly Megan
 
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
AugmentedWorldExpo
 
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONELUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
Microsoft Mobile Developer
 
Android - Android Application Configuration
Android - Android Application ConfigurationAndroid - Android Application Configuration
Android - Android Application Configuration
Vibrant Technologies & Computers
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in android
Angelo Rüggeberg
 

Similar to Map (20)

Augmented Reality on iPhone Applications
Augmented Reality on iPhone ApplicationsAugmented Reality on iPhone Applications
Augmented Reality on iPhone Applications
 
Intro To Google Maps
Intro To Google MapsIntro To Google Maps
Intro To Google Maps
 
@Ionic native/google-maps
@Ionic native/google-maps@Ionic native/google-maps
@Ionic native/google-maps
 
Android application for gps
Android application for gpsAndroid application for gps
Android application for gps
 
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
 
Geolocation and Mapping
Geolocation and MappingGeolocation and Mapping
Geolocation and Mapping
 
Android mobile application for gps
Android mobile application for gpsAndroid mobile application for gps
Android mobile application for gps
 
Processing 2.0 + Open Data
Processing 2.0 + Open DataProcessing 2.0 + Open Data
Processing 2.0 + Open Data
 
Maps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkokMaps API on_mobile_dev_festbangkok
Maps API on_mobile_dev_festbangkok
 
Sirius Web Advanced : Customize and Extend the Platform
Sirius Web Advanced : Customize and Extend the PlatformSirius Web Advanced : Customize and Extend the Platform
Sirius Web Advanced : Customize and Extend the Platform
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
 
Integrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS AppIntegrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS App
 
Philipp Nagele (Wikitude): What's Next with Wikitude
Philipp Nagele (Wikitude): What's Next with WikitudePhilipp Nagele (Wikitude): What's Next with Wikitude
Philipp Nagele (Wikitude): What's Next with Wikitude
 
Angular google maps tutorial quick guide
Angular google maps tutorial quick guideAngular google maps tutorial quick guide
Angular google maps tutorial quick guide
 
ARCore 101: A Hands-on Workshop
ARCore 101: A Hands-on WorkshopARCore 101: A Hands-on Workshop
ARCore 101: A Hands-on Workshop
 
Create Location Sharing apps using the Ionic framework
Create Location Sharing apps using the Ionic framework					Create Location Sharing apps using the Ionic framework
Create Location Sharing apps using the Ionic framework
 
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
Philipp Nagele (CTO, Wikitude) An Insider Deep-Dive into the Wikitude SDK
 
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONELUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
 
Android - Android Application Configuration
Android - Android Application ConfigurationAndroid - Android Application Configuration
Android - Android Application Configuration
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in android
 

More from Training Guide

Persistences
PersistencesPersistences
Persistences
Training Guide
 
Theads services
Theads servicesTheads services
Theads services
Training Guide
 
Application lifecycle
Application lifecycleApplication lifecycle
Application lifecycle
Training Guide
 
Deployment
DeploymentDeployment
Deployment
Training Guide
 
Getting started
Getting startedGetting started
Getting started
Training Guide
 
Intents broadcastreceivers
Intents broadcastreceiversIntents broadcastreceivers
Intents broadcastreceivers
Training Guide
 
Tdd
TddTdd

More from Training Guide (7)

Persistences
PersistencesPersistences
Persistences
 
Theads services
Theads servicesTheads services
Theads services
 
Application lifecycle
Application lifecycleApplication lifecycle
Application lifecycle
 
Deployment
DeploymentDeployment
Deployment
 
Getting started
Getting startedGetting started
Getting started
 
Intents broadcastreceivers
Intents broadcastreceiversIntents broadcastreceivers
Intents broadcastreceivers
 
Tdd
TddTdd
Tdd
 

Recently uploaded

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 

Recently uploaded (20)

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 

Map

  • 2. l l l Maps Google Maps API is widely used on the web The Android SDK provides support for easily integrating the Google Maps API
  • 3. l l l Using Google Maps in our apps Configure l Maps require the Google API as the project build target l Maps require a Map API Key in order to be deployed l http://code.google.com/android/add-ons/googleapis/maps-overview.html Code l Create a MapView in a MapActivity l Create Map Overlays
  • 4. l Add Google API in Eclipse • http://developer.android.com/sdk/adding-components.html
  • 5. l l Add Google API in Eclipse Use API 4 for SDK 1.6 – http://developer.android.com/guide/appendix/api-levels.html
  • 6. l l Add Google API in Eclipse Set the Google API as the Project Build Target l Right-click on the project, select Properties
  • 7. l l • l l Keys As we learned in lab 1 section 6, – https://sites.google.com/site/androidappcourse/labs/lab-1 our apps must be signed in order to deploy them on a device Eclipse automatically creates a signed debug keystore that is used when launching our app from Eclipse In order to deploy our app to the public, we must create a signed keystore – See http://developer.android.com/guide/publishing/appsigning.html#ExportWizard
  • 8. l Find your keystore • http://code.google.com/android/add-ons/googleapis/mapkey.html
  • 9. l Find your debug keystore • http://code.google.com/android/add-ons/googleapis/mapkey.html
  • 10. l Get your certificate fingerprint • http://code.google.com/android/add-ons/googleapis/mapkey.html
  • 11. l Register your certificate with Google • http://code.google.com/android/maps-api-signup.html
  • 12. l Add the Map API Key to your Application • <com.google.android.maps.MapView • android:id="@+id/myMap" • android:layout_width="fill_parent" • android:layout_height="fill_parent" • android:clickable="true" • android:apiKey="@string/mapApiKey"/>
  • 13. l l l What’s in the legal agreement? Read the Terms of Service (sections 1-11) l http://code.google.com/android/maps-api-signup.html Examples l Maps may include ads in future l Google may limit number of transactions l Cannot use for turn-by-turn directions or autonomous driving
  • 14. l Configure AndroidManifest.xml • <application android:name="MyApplication" > • <uses-library android:name="com.google.android.maps" /> • ... • </application>
  • 15. l l Finally, we can start coding MapView l Contains a map l via Google Maps API l Map tile retrieval and caching is all done for you l Includes pan l Includes zoom l use setBuiltInZoomControls(true);
  • 16. l l MapActivity MapView can only be constructed or inflated in a MapActivity • public class MyActivity extends MapActivity { •… • @Override • public void onCreate(Bundle savedInstanceState) { • super.onCreate(savedInstanceState); • … • MapView myMap = (MapView)findViewById(R.id.myMap); • myMap.setBuiltInZoomControls(); • myMap.setSatellite(true);
  • 17. l l MapView Modes MapView l You determine mode l setSatellite(true); l setTraffic(true); l setStreetView(true);
  • 18. l l • • • • • • • MapController You can pan and zoom the map programmatically MapView myMap = (MapView)findViewById(R.id.myMap); MapController mapController = myMap.getController(); mapController.setZoom(1); //widest zoom/far away … mapController.setZoom(21); //narrowest zoom/close in mapController.zoomIn(); //one level mapController.zoomOut(); //one level
  • 19. l l GeoPoint You can move to a particular point • • MapView myMap = (MapView)findViewById(R.id.myMap); MapController mapController = myMap.getController(); • • • • • • Double lat = 37.123456 * 1E6; Double long = -122.123456 * 1E6; GeoPoint point = new GeoPoint(lat.intValue(), long.intValue()); mapController.setCenter(point); //jump to point … mapController.animateTo(point); //smooth transition to point
  • 20. l l Reverse Geocoding Find address from longitude/latitude • • • • • • • • • • location = locationManager.getLastKnownLocation( LocationManager.GPS_PROVIDER); double lat = location.getLatitude(); double lng = location.getLongitude(); Geocoder gc = new Geocoder(this, Locale.getDefault()); List<Address> addresses = null; try { addresses = gc.getFromLocation(lat, lng, 10); } catch (IOException e) {}
  • 21. l l Forward Geocoding Find longitude/latitude (and more) from address • • • • • • • • Geocoder gc = new Geocoder(this, Locale.US); List<Address> addresses = null; try { addresses = gc.getFromLocationName( “123 Main St., Newton, Kansas”, 10); } catch (IOException e) {} double lat = addresses.get(0).getLatitude(); String zip = addresses.get(0).getPostalCode();
  • 22. l l Geolocation Options l GPS, cell network l Wifi-based l Skyhook Wireless l http://www.skyhookwireless.com/developers/Android_Integration_M anual.php
  • 23. l • • • • • • • • • • • • • • • • • • Setting up location services public MyActivity() { criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); }; private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider) { updateWithNewLocation(null); } public void onProviderEnabled(String provider) {} public void onStatusChanged(String provider, int status, Bundle extras) {} };
  • 24. • • • • • • • • • • • • • • • • • • • • • • @Override protected void onStart() { super.onStart(); locationManager = (LocationManager)getSystemService( Context.LOCATION_SERVICE); provider = locationManager.getBestProvider(criteria, true); // or could be LocationManager.GPS_PROVIDER try { updateWithNewLocation(locationManager.getLastKnownLocation( provider)); } catch (Exception e) {} locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); } private void updateWithNewLocation(Location location) { double latitude = 0.0; double longitude = 0.0; if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); //do something with latitude and longitude (e.g. print or move map there) }
  • 25. l • • • • • • • • • Turn GPS on and off to save battery @Override protected void onPause() { super.onPause(); //stop receiving GPS locationManager.removeUpdates(locationListener); } @Override protected void onResume() { super.onResume(); //restart receiving GPS locationManager.requestLocationUpdates(provider, 2000, 10, • locationListener); • }