SlideShare a Scribd company logo
1 of 23
Download to read offline
Copyright © 2013 CommonsWare, LLC
MapsV2...
AndYou!
AnDevCon Boston 2013
Copyright © 2013 CommonsWare, LLC
Maps: Not Invented in 2008!
● Android 1.0: Maps SDK Add-On
– Same as what Google Maps app used
– Creaky API, particularly with fragments
● The Fork
– Google Maps started using own engine
– Gained more features than old SDK add-on
supported
Copyright © 2013 CommonsWare, LLC
Maps: Not Invented In 2012 Either!
● MapsV2
– Introduced in late 2012
– New API, new device requirements, new features
● Close to full Google Maps app
● MapsV1: Deprecated!
– Can no longer official get MapsV1 API keys
– Still runs, if you have keys from before
Copyright © 2013 CommonsWare, LLC
Legal, Without Ease
● MapsV1 and MapsV2:Terms of Service
– Required to use these APIs
– Put restrictions on how you use those APIs
● Example: no real-time turn-by-turn navigation
– IANALNDIPOOTV
● Please have qualified legal counsel review these
terms if they concern you
Copyright © 2013 CommonsWare, LLC
Users Have Issues (No, Really!)
● Requirements
– Play Services Framework
● May already exist
● May be available from the Play Store
● Not available by other legitimate means
– OpenGL ES 2.0
● On 99.8% of devices with the Play Store
Copyright © 2013 CommonsWare, LLC
You Have IssuesToo
● No Emulator Support
– Play Services Framework not available in
emulator images
● Google has indicated this will be resolved...
sometime
– Various workarounds of dubious legality
documented on teh Interwebs
● Expectation:Test on Hardware
Copyright © 2013 CommonsWare, LLC
Preparation M
● Setting Up MapsV2 Development
– Download Google Play Services SDK from SDK
Manager (in Extras area)
– Result: Android Library Project
● Eclipse: import into workspace, then attach to
application project
● Command-line: android update project
● Other IDEs: ???
Copyright © 2013 CommonsWare, LLC
Yet More Preparation M
● MapsV2 API Key
– No, it's not the same as your MapsV1 API key
– Obtain it from the Google API Console
– Tied to your package name, signing key
● SHA-1 fingerprint vs. MD5
● Up to ~5 signing key/package name pairs per API key
Copyright © 2013 CommonsWare, LLC
Let's Get Mappy, People
● A MapsV2 Project
– ...does not need to use a Google APIs SDK as a
build target
– …does need to restrict to OpenGL ES 2.0 devices
● Or make optional, but test at runtime
– ...does need permissions, including a custom one
– ...does need a MapsV2 API key
Copyright © 2013 CommonsWare, LLC
Let's Get Mappy, People
● A MapsV2 Activity
– ...does not have to inherit from any magic
activity class
– ...does need to use MapFragment,
SupportMapFragment, or MapView
– ...does have a lot of legwork to ensure MapsV2 is
available, the user has access to license terms,
etc.
● ...all of which can be nicely abstracted away
Copyright © 2013 CommonsWare, LLC
Working (with a map) For a Living
● GoogleMap
– Your gateway to the actual mapping API
– Obtained from MapFragment,
SupportMapFragment, or MapView via
getMap()
– Most method calls result in IPC
● Comparatively slow
● Avoid doing lots of these in a tight loop
● Must be called on the main application thread
Copyright © 2013 CommonsWare, LLC
Showing Something Useful
● CameraUpdate
– Changes in characteristics of the “camera”
● Center, zoom, etc.
– Create using CameraUpdateFactory
– Apply to GoogleMap
● moveCamera()
● animateCamera()
Copyright © 2013 CommonsWare, LLC
Typing Up a Map
● Default MapType: MAP_TYPE_NORMAL
● Changing MapTypes
– Choose a type (e.g., MAP_TYPE_HYBRID)
– Call setMapType() on your GoogleMap
Copyright © 2013 CommonsWare, LLC
Marking Up a Map
● No More Overlays!
● Add MarkersVia addMarker()
– Takes a MarkerOptions object
– Fluent API to describe marker
– Position as a LatLng
● No more microdegrees!
– Provide title and snippet for default pop-up
“info window”
Copyright © 2013 CommonsWare, LLC
BYO Info
● Controlling the InfoWindows
– Implement InfoWindowAdapter interface
● getInfoContents(): your ownView to pour into
MapsV2-supplied frame
● getInfoWindow(): your ownView with your own
frame
– Associate with GoogleMap via
setInfoWindowAdapter()
Copyright © 2013 CommonsWare, LLC
Taps, Sans Bugle
● MarkerTaps
– Implement OnMarkerClickListener interface
● onMarkerClick() called when user taps on a
Marker
– Associate with GoogleMap via
setOnMarkerClickListener()
Copyright © 2013 CommonsWare, LLC
Markers Can Be a Real Drag
● Marker Drag-and-Drop
– Call draggable(true) on MarkerOptions
– Implement OnMarkerDragListener interface
● onMarkerDragStart()
● onMarkerDrag()
● onMarkerDragEnd()
– Associate with GoogleMap via
setOnMarkerDragListener()
Copyright © 2013 CommonsWare, LLC
WhereYou At?
● Enabling “My Location”
– setMyLocationEnabled(true) on
GoogleMap
● Adds “My Location” button
● Requires suitable permissions (e.g.,
ACCESS_FINE_LOCATION)
● When tapped, camera follows the user
– OnMyLocationChangeListener and
setOnMyLocationChangeListener()
Copyright © 2013 CommonsWare, LLC
Pages of Maps
● MapFragment andViewPager
– It just works!
● Problem:ViewPagerWants Gestures
– Default: cannot pan map horizontally
– Solution: CustomViewPager subclass, overriding
canScroll(), to indicate widgets that handle
their own scrolling
Copyright © 2013 CommonsWare, LLC
Dirty Details, Done Dirt Cheap
● AbstractMapActivity Features
– Determining if Play Services Framework is
available
– Leading user to install Play Services Framework
if possible
– Showing license terms
Copyright © 2013 CommonsWare, LLC
Other Fun Stuff
● Supplying own location data
● Polylines, polygons, and circles
● Controlling default gestures
● TileOverlay and GroundOverlay
– Images displayed on top of map tiles
● ...and more!
Copyright © 2013 CommonsWare, LLC
Do Worry, Be Mappy
● Problems and Issues
– Reported leaks in configuration changes
– GLSurfaceView, animations, and black bars
– Play Services Framework detection buggy
– IPC and performance
– OpenGL ES 2.0 requirement
Copyright © 2013 CommonsWare, LLC
Speaker Contact
Information
Source Code

More Related Content

What's hot

What's hot (10)

Android Modularization
Android ModularizationAndroid Modularization
Android Modularization
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
 
Angular
AngularAngular
Angular
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Qt Technical Presentation
Qt Technical PresentationQt Technical Presentation
Qt Technical Presentation
 
When Microwatts Are Precious: Battery Tips for Wearable Apps
When Microwatts Are Precious: Battery Tips for Wearable AppsWhen Microwatts Are Precious: Battery Tips for Wearable Apps
When Microwatts Are Precious: Battery Tips for Wearable Apps
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Building the Developer Experience Right - May The Force of API Be With You
Building the Developer Experience Right - May The Force of API Be With YouBuilding the Developer Experience Right - May The Force of API Be With You
Building the Developer Experience Right - May The Force of API Be With You
 
GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)GWT - AppDays - (25 aprile 2014, pordenone)
GWT - AppDays - (25 aprile 2014, pordenone)
 
3D Programming Basics: WebGL
3D Programming Basics: WebGL3D Programming Basics: WebGL
3D Programming Basics: WebGL
 

Viewers also liked

Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 

Viewers also liked (17)

Cara Daftar Google Map
Cara Daftar Google MapCara Daftar Google Map
Cara Daftar Google Map
 
Study of the Source code of Google's Android App mytracks
Study of the Source code of Google's  Android App mytracks Study of the Source code of Google's  Android App mytracks
Study of the Source code of Google's Android App mytracks
 
Android google mapv2
Android google mapv2Android google mapv2
Android google mapv2
 
Panduan Instalasi Android Studio
Panduan Instalasi Android StudioPanduan Instalasi Android Studio
Panduan Instalasi Android Studio
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Day 1 Android: Before Getting Started
Day 1 Android: Before Getting StartedDay 1 Android: Before Getting Started
Day 1 Android: Before Getting Started
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location API
 
Belajar Android PHP MySQL Login dengan Volley
Belajar Android PHP MySQL Login dengan VolleyBelajar Android PHP MySQL Login dengan Volley
Belajar Android PHP MySQL Login dengan Volley
 
Android Fast Track CRUD Android PHP MySql
Android Fast Track CRUD Android PHP MySqlAndroid Fast Track CRUD Android PHP MySql
Android Fast Track CRUD Android PHP MySql
 
Belajar Android Studio CRUD Data Mahasiswa
Belajar Android Studio CRUD Data MahasiswaBelajar Android Studio CRUD Data Mahasiswa
Belajar Android Studio CRUD Data Mahasiswa
 
Belajar Android Membuat Katalog Produk
Belajar Android Membuat Katalog ProdukBelajar Android Membuat Katalog Produk
Belajar Android Membuat Katalog Produk
 
Cara Membuat Aplikasi Android Resep Masakan Sederhana Android-SQLite
Cara Membuat Aplikasi Android Resep Masakan Sederhana Android-SQLiteCara Membuat Aplikasi Android Resep Masakan Sederhana Android-SQLite
Cara Membuat Aplikasi Android Resep Masakan Sederhana Android-SQLite
 
Belajar Android Studio - Membuat Aplikasi Android Sederhana
Belajar Android Studio - Membuat Aplikasi Android SederhanaBelajar Android Studio - Membuat Aplikasi Android Sederhana
Belajar Android Studio - Membuat Aplikasi Android Sederhana
 
Tutorial Lengkap Cara Membuat Aplikasi Android Sederhana
Tutorial Lengkap Cara Membuat Aplikasi Android SederhanaTutorial Lengkap Cara Membuat Aplikasi Android Sederhana
Tutorial Lengkap Cara Membuat Aplikasi Android Sederhana
 

Similar to Maps V2... And You!

sdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_publicsdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_public
Rick Lau
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
Aleix Solé
 
PT GTUG 1st Technical Tession - Android
PT GTUG 1st Technical Tession - AndroidPT GTUG 1st Technical Tession - Android
PT GTUG 1st Technical Tession - Android
drjuniornet
 

Similar to Maps V2... And You! (20)

sdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_publicsdc-2016-gvrf-and-io_public
sdc-2016-gvrf-and-io_public
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
 
Begining Android Development
Begining Android DevelopmentBegining Android Development
Begining Android Development
 
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial Philipp Nagele (Wikitude) Wikitude SDK Tutorial
Philipp Nagele (Wikitude) Wikitude SDK Tutorial
 
Introduction to Android - Mobile Fest Singapore 2009
Introduction to Android - Mobile Fest Singapore 2009Introduction to Android - Mobile Fest Singapore 2009
Introduction to Android - Mobile Fest Singapore 2009
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
 
[English] Create Mobile LBS Application Using Maps API
[English] Create Mobile LBS Application Using Maps API[English] Create Mobile LBS Application Using Maps API
[English] Create Mobile LBS Application Using Maps API
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
 
PT GTUG 1st Technical Tession - Android
PT GTUG 1st Technical Tession - AndroidPT GTUG 1st Technical Tession - Android
PT GTUG 1st Technical Tession - Android
 
App integration: Strategies and Tactics
App integration: Strategies and TacticsApp integration: Strategies and Tactics
App integration: Strategies and Tactics
 
Introduction to Android - Mobile Portland
Introduction to Android - Mobile PortlandIntroduction to Android - Mobile Portland
Introduction to Android - Mobile Portland
 
App Integration (Revised and Updated)
App Integration (Revised and Updated)App Integration (Revised and Updated)
App Integration (Revised and Updated)
 
Cross Platform Mobile App Development
Cross Platform Mobile App DevelopmentCross Platform Mobile App Development
Cross Platform Mobile App Development
 
Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)
 
Android Development...The 20,000-Foot View
Android Development...The 20,000-Foot ViewAndroid Development...The 20,000-Foot View
Android Development...The 20,000-Foot View
 
Latest & interesting updates #android dev
Latest & interesting updates #android devLatest & interesting updates #android dev
Latest & interesting updates #android dev
 
Map
MapMap
Map
 
Angular JS 2_0 BCS CTO_in_Res V3
Angular JS 2_0 BCS CTO_in_Res V3Angular JS 2_0 BCS CTO_in_Res V3
Angular JS 2_0 BCS CTO_in_Res V3
 
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
 
Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012
 

More from CommonsWare

Gradle and Your Android Wearable Projects
Gradle and Your Android Wearable ProjectsGradle and Your Android Wearable Projects
Gradle and Your Android Wearable Projects
CommonsWare
 

More from CommonsWare (20)

Gradle and Your Android Wearable Projects
Gradle and Your Android Wearable ProjectsGradle and Your Android Wearable Projects
Gradle and Your Android Wearable Projects
 
Getting Android Developers for Your Wearables
Getting Android Developers for Your WearablesGetting Android Developers for Your Wearables
Getting Android Developers for Your Wearables
 
The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to Back
 
Android Security: Defending Your Users
Android Security: Defending Your UsersAndroid Security: Defending Your Users
Android Security: Defending Your Users
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful Threading
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot View
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPager
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web Apps
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile Web
 
X Means Y
X Means YX Means Y
X Means Y
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of Wearables
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipher
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFC
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly Bean
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business Models
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld Keynote
 
Rich Text Editing and Beyond
Rich Text Editing and BeyondRich Text Editing and Beyond
Rich Text Editing and Beyond
 
Backwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and TacticsBackwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and Tactics
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Maps V2... And You!

  • 1. Copyright © 2013 CommonsWare, LLC MapsV2... AndYou! AnDevCon Boston 2013
  • 2. Copyright © 2013 CommonsWare, LLC Maps: Not Invented in 2008! ● Android 1.0: Maps SDK Add-On – Same as what Google Maps app used – Creaky API, particularly with fragments ● The Fork – Google Maps started using own engine – Gained more features than old SDK add-on supported
  • 3. Copyright © 2013 CommonsWare, LLC Maps: Not Invented In 2012 Either! ● MapsV2 – Introduced in late 2012 – New API, new device requirements, new features ● Close to full Google Maps app ● MapsV1: Deprecated! – Can no longer official get MapsV1 API keys – Still runs, if you have keys from before
  • 4. Copyright © 2013 CommonsWare, LLC Legal, Without Ease ● MapsV1 and MapsV2:Terms of Service – Required to use these APIs – Put restrictions on how you use those APIs ● Example: no real-time turn-by-turn navigation – IANALNDIPOOTV ● Please have qualified legal counsel review these terms if they concern you
  • 5. Copyright © 2013 CommonsWare, LLC Users Have Issues (No, Really!) ● Requirements – Play Services Framework ● May already exist ● May be available from the Play Store ● Not available by other legitimate means – OpenGL ES 2.0 ● On 99.8% of devices with the Play Store
  • 6. Copyright © 2013 CommonsWare, LLC You Have IssuesToo ● No Emulator Support – Play Services Framework not available in emulator images ● Google has indicated this will be resolved... sometime – Various workarounds of dubious legality documented on teh Interwebs ● Expectation:Test on Hardware
  • 7. Copyright © 2013 CommonsWare, LLC Preparation M ● Setting Up MapsV2 Development – Download Google Play Services SDK from SDK Manager (in Extras area) – Result: Android Library Project ● Eclipse: import into workspace, then attach to application project ● Command-line: android update project ● Other IDEs: ???
  • 8. Copyright © 2013 CommonsWare, LLC Yet More Preparation M ● MapsV2 API Key – No, it's not the same as your MapsV1 API key – Obtain it from the Google API Console – Tied to your package name, signing key ● SHA-1 fingerprint vs. MD5 ● Up to ~5 signing key/package name pairs per API key
  • 9. Copyright © 2013 CommonsWare, LLC Let's Get Mappy, People ● A MapsV2 Project – ...does not need to use a Google APIs SDK as a build target – …does need to restrict to OpenGL ES 2.0 devices ● Or make optional, but test at runtime – ...does need permissions, including a custom one – ...does need a MapsV2 API key
  • 10. Copyright © 2013 CommonsWare, LLC Let's Get Mappy, People ● A MapsV2 Activity – ...does not have to inherit from any magic activity class – ...does need to use MapFragment, SupportMapFragment, or MapView – ...does have a lot of legwork to ensure MapsV2 is available, the user has access to license terms, etc. ● ...all of which can be nicely abstracted away
  • 11. Copyright © 2013 CommonsWare, LLC Working (with a map) For a Living ● GoogleMap – Your gateway to the actual mapping API – Obtained from MapFragment, SupportMapFragment, or MapView via getMap() – Most method calls result in IPC ● Comparatively slow ● Avoid doing lots of these in a tight loop ● Must be called on the main application thread
  • 12. Copyright © 2013 CommonsWare, LLC Showing Something Useful ● CameraUpdate – Changes in characteristics of the “camera” ● Center, zoom, etc. – Create using CameraUpdateFactory – Apply to GoogleMap ● moveCamera() ● animateCamera()
  • 13. Copyright © 2013 CommonsWare, LLC Typing Up a Map ● Default MapType: MAP_TYPE_NORMAL ● Changing MapTypes – Choose a type (e.g., MAP_TYPE_HYBRID) – Call setMapType() on your GoogleMap
  • 14. Copyright © 2013 CommonsWare, LLC Marking Up a Map ● No More Overlays! ● Add MarkersVia addMarker() – Takes a MarkerOptions object – Fluent API to describe marker – Position as a LatLng ● No more microdegrees! – Provide title and snippet for default pop-up “info window”
  • 15. Copyright © 2013 CommonsWare, LLC BYO Info ● Controlling the InfoWindows – Implement InfoWindowAdapter interface ● getInfoContents(): your ownView to pour into MapsV2-supplied frame ● getInfoWindow(): your ownView with your own frame – Associate with GoogleMap via setInfoWindowAdapter()
  • 16. Copyright © 2013 CommonsWare, LLC Taps, Sans Bugle ● MarkerTaps – Implement OnMarkerClickListener interface ● onMarkerClick() called when user taps on a Marker – Associate with GoogleMap via setOnMarkerClickListener()
  • 17. Copyright © 2013 CommonsWare, LLC Markers Can Be a Real Drag ● Marker Drag-and-Drop – Call draggable(true) on MarkerOptions – Implement OnMarkerDragListener interface ● onMarkerDragStart() ● onMarkerDrag() ● onMarkerDragEnd() – Associate with GoogleMap via setOnMarkerDragListener()
  • 18. Copyright © 2013 CommonsWare, LLC WhereYou At? ● Enabling “My Location” – setMyLocationEnabled(true) on GoogleMap ● Adds “My Location” button ● Requires suitable permissions (e.g., ACCESS_FINE_LOCATION) ● When tapped, camera follows the user – OnMyLocationChangeListener and setOnMyLocationChangeListener()
  • 19. Copyright © 2013 CommonsWare, LLC Pages of Maps ● MapFragment andViewPager – It just works! ● Problem:ViewPagerWants Gestures – Default: cannot pan map horizontally – Solution: CustomViewPager subclass, overriding canScroll(), to indicate widgets that handle their own scrolling
  • 20. Copyright © 2013 CommonsWare, LLC Dirty Details, Done Dirt Cheap ● AbstractMapActivity Features – Determining if Play Services Framework is available – Leading user to install Play Services Framework if possible – Showing license terms
  • 21. Copyright © 2013 CommonsWare, LLC Other Fun Stuff ● Supplying own location data ● Polylines, polygons, and circles ● Controlling default gestures ● TileOverlay and GroundOverlay – Images displayed on top of map tiles ● ...and more!
  • 22. Copyright © 2013 CommonsWare, LLC Do Worry, Be Mappy ● Problems and Issues – Reported leaks in configuration changes – GLSurfaceView, animations, and black bars – Play Services Framework detection buggy – IPC and performance – OpenGL ES 2.0 requirement
  • 23. Copyright © 2013 CommonsWare, LLC Speaker Contact Information Source Code