Maps Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 4 Overview Overview of Sensors Programming Tutorial 1: Tracking location with GPS and Google.
Advertisements

Google APIs & Location Based Applications -Krishna Achanta
Bruce Scharlau, University of Aberdeen, 2010 Android and Location Mobile Computing Unless otherwise stated, images are from android sdk.
Introducing to Location in Android LOCATION IS EVERYTHING Kamil Lelonek Kamil Lelonek
CS378 - Mobile Computing Maps. Using Google Maps Like other web services requires an API key from Google ons/google-apis/mapkey.html.
Chapter 11: Discover! Incorporating Google Maps
Location-Based Services: Part 2 (Google Maps)
Google Android Map API Presentation 13/03/2008. Map API – Overview (1) Map rendering facility on Android device Similar to Google Earth Integrate map.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Location & Maps.  Mobile applications can benefit from being location-aware, e.g.,  Routing from a current to a desired location  Searching for stores.
GPS and MapView. First In the emulator, set the time zone to something (e.g., east coast) and check that the time is correct. Otherwise, the gps emulator.
Android wifi-based localization. Localization types Android allows (location providers) – GPS (GPS_PROVIDER) – Cell tower + wifi (NETWORK_PROVIDER) You.
Location and Maps Content Getting Location Getting Google Map In application Test on Emulator/Device.
Android Tutorial Larry Walters OOSE Fall References This tutorial is a brief overview of some major concepts…Android is much richer and more complex.
CS378 - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives: Open Street Maps –
Map Applications.
Android Sensors & Async Callbacks Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
Route Tracker App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Mobile Application Development Selected Topics – CPIT 490
Google Maps Android API v2 吳俊興 國立高雄大學 資訊工程學系 CSF645 – Mobile Computing 行動計算
Location Services: Part 1 (Location and Geocoding)
Location based services Using Google Maps v2 etc. in Android apps 1Location based services.
Mobile Programming Lecture 9 Bound Service, Location, Sensors, IntentFilter.
1 Localization and Sensing Nilanjan Banerjee Mobile Systems Programming (Acknowledgement: Jules White) University of Arkansas Fayetteville, AR
Mobile Programming Lecture 16 The Facebook API. Agenda The Setup Hello, Facebook User Facebook Permissions Access Token Logging Out Graph API.
Social network Twitter Hashtag: #m2eu #android Personal Israel Ferrer –
Location based services
CSS216 MOBILE PROGRAMMING Android, Chapter 8 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
Cosc 5/4730 Broadcast Receiver. Broadcast receiver A broadcast receiver (short receiver) – is an Android component which allows you to register for system.
Android Accessing GPS Ken Nguyen Clayton State University 2012.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Threads and Services. Background Processes One of the key differences between Android and iPhone is the ability to run things in the background on Android.
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
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.
Android Application Lifecycle and Menus
Sensors – Part 2 SE 395/595. Location in Android LocationManager class – Configure providers and their listeners LocationListener class – Handles update.
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Cosc 5/4735 YouTube API. YouTube The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications.
Cosc 4735 LocationAware API. Previous on … Before we looked at GPS location. – d-gpslocation.pptx
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
GPS and MapView. First In the emulator, set the time zone to something (e.g., east coast) and check that the time is correct. Otherwise, the gps emulator.
Lecture 5: Location Topics: Google Play Services, Location API Date: Feb 16, 2016.
CS371m - Mobile Computing Maps. Using Google Maps Content on using Google Maps inside your app Alternatives Exist: – Open Street Maps –
3 rd -party APIs Kalin Kadiev Astea Solutions AD.
1. 2 Android location services Determining a device’s current location Tracking device movements Proximity alerts.
Location-Based Services. Objectives How to display Google Maps in your application How to control displayed maps How to perform geocoding and reverse.
CS499 – Mobile Application Development Fall 2013 Location & Maps.
Lecture 5: Location Topics: Google Play Services, Location API
Location Services: Part 1 (Location and Geocoding)
Android Application Maps 1.
Tracking device movements
Lecture 5: Location Topics: Google Play Services, Location API.
Location-Based Services: Part 2 (Google Maps)
AnDroid GoogleMaps API
Designing Apps Using The WebView Control
Android Location Based Services
Sensors, maps and fragments:
Location Service and Sensors
תכנות ב android אליהו חלסצ'י.
CS371m - Mobile Computing Maps.
CIS 470 Mobile App Development
Activities and Intents
CIS 470 Mobile App Development
Lecture 5: Location Topics: Google Play Services, Location API.
Mobile Programming Dr. Mohsin Ali Memon.
Maps, Geocoding, and Location-Based Services.
Mobile Programming Dr. Mohsin Ali Memon.
Presentation transcript:

Maps Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.

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

Using Google Maps in our apps Configure –Maps require the Google API as the project build target –Maps require a Map API Key in order to be deployed – ons/google-apis/maps-overview.html Code –Create a MapView in a MapActivity –Create Map Overlays

Add Google API in Eclipse

Add Google API in Eclipse Use API 4 for SDK 1.6

Add Google API in Eclipse Set the Google API as the Project Build Target –Right-click on the project, select Properties

Keys As we learned in lab 1 section 6, 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 signing.html#ExportWizard

Find your keystore

Find your debug keystore

Get your certificate fingerprint

Register your certificate with Google

What’s in the legal agreement? Read the Terms of Service (sections 1-11) – signup.html Examples –Maps may include ads in future –Google may limit number of transactions –Cannot use for turn-by-turn directions or autonomous driving

Add the Map API Key to your Application <com.google.android.maps.MapView android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true"

Configure AndroidManifest.xml...

Finally, we can start coding MapView –Contains a map via Google Maps API Map tile retrieval and caching is all done for you –Includes pan –Includes zoom use setBuiltInZoomControls(true);

MapView Modes MapView –You determine mode setSatellite(true); setTraffic(true); setStreetView(true);

MapActivity MapView can only be constructed or inflated in a MapActivity public class MyActivity extends MapActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); … MapView myMap = (MapView)findViewById(R.id.myMap); myMap.setBuiltInZoomControls(); myMap.setSatellite(true);

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

GeoPoint You can move to a particular point MapView myMap = (MapView)findViewById(R.id.myMap); MapController mapController = myMap.getController(); Double lat = * 1E6; Double long = * 1E6; GeoPoint point = new GeoPoint(lat.intValue(), long.intValue()); mapController.setCenter(point); //jump to point … mapController.animateTo(point); //smooth transition to point

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 addresses = null; try { addresses = gc.getFromLocation(lat, lng, 10); } catch (IOException e) {}

Forward Geocoding Find longitude/latitude (and more) from address Geocoder gc = new Geocoder(this, Locale.US); List 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();

Geolocation Options –GPS, cell network –Wifi-based Skyhook Wireless Android_Integration_Manual.php

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) }

Turn GPS on and off to save protected void onPause() { super.onPause(); //stop receiving GPS locationManager.removeUpdates(locationListener); protected void onResume() { super.onResume(); //restart receiving GPS locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); }