Scaling API-first – The story of a global engineering organization
Mapping on iOS and Android, Wally McClure
1. Location
Based
Services
and
Mapping
with
iOS
Wallace
B.
McClure
Scalable
Development,
Inc.
Twi;er:
@wbm
Email:
wallym@scalabledevelopment.com
Phone:
865-‐740-‐3004
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
2. Me.About()
• Wally
McClure
• Scalable
Development,
Inc.
• MicrosoQ
ASP.NET
MVP
• ASPInsider
• Legend
in
his
own
mind
• Author
• Scalable
Development,
Inc.
• wallym@scalabledevelopment.com
• 865-‐740-‐3004
• Twi;er,
Facebook,
LinkedIn,
…
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
3. Agenda
–
Mapping
in
iOS
• LocaXon
Based
Services
• Apple
Maps
• Mapping
with
Android
• Google
Maps
for
iOS
SDK
–
Sample
Code
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
4. Determine
Location
• GPS
• Cellular
TriangulaXon
• Wifi
lookup
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
5. Namespaces
• MapKit
• Apple
Framework
for
Mapping
• MonoTouch.MapKit.MKMapView
class
• CoreLocaXon
• Apple
Framework
for
LocaXon
Services
• MonoTouch.CoreLocaXon
• CLLocaXonManager
• Points
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
6. Displaying
Maps
• MapKit
• LaXtude/Longitude
• Center
• Region
to
display
• Google
Maps
uses
ZoomLevel
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
7. Map
Properties
• MKMapView
• Region
• Span
• Center
• ShowUserLocaXon
• MapType
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
8. Annotating
Maps
• Points
on
a
map
• Inherit
–
MKAnnotaXon
• Point
• Title
• Overlays
• Add/Remove
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
9. Displaying
Overlays
• Shapes
• Colors
• Ex:
5
km
gray
circle
• Standard
Shapes
• Custom
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
10. Map
Movement
• Map
Delegate
• Inherit
from
MKMapViewDelegate
• Region
Changed
Override
• Communicate
back
to
the
parent
• Example
Now
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
11. Location
and
Change
Events
• LocaXon
changes
• StartLocaXonChanges()
• StartMonitoringSignificantLocaXonChanges()
• UpdatedLocaXons
Event
• StartUpdaXngHeading()
• Choose
the
right
mechanism
• Be
a
good
ciXzen
on
the
device
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
12. Background
Processing
-‐
Info.plist
• Requires
locaXon
service
• Availability
of
locaXon
services
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
13. Region
Monitoring
• Need:
• Point/Center
• Radius
• Check
when
device
crosses
a
boundary
• IdenXfier
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
14. Tips
for
Conserving
Battery
• Turn
off
locaXon
services
when
not
used
• Use
the
significant
change
locaXon
service
when
possible
• Use
lower
resoluXon
for
desired
accuracy
when
possible
• Turn
off
locaXon
events
if
the
accuracy
does
not
improve
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
15. Geocoding
• Forward
• Reverse
• Network
connecXon
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
16. Forward
Geocoding
(iOS5)
• LocaXon
-‐>
lat/lon
pair
• Not
in
iOS
3
or
4
• In
iOS
5+!
• CLGeocoder
• .GeocodeAddress
• Async!
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
17. Reverse
Geocoding
• BuilXn
• Lat/Lon
-‐>
Address
• Built
in
• Async
• Network
connecXon
• Examples
in
Forward
and
Reverse
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
18. But
Apple
Maps
Has
Problems
• Google
Maps
for
iOS
SDK
• Xamarin.iOS
bindings
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
19. Switch
to
Android
• Different
ways
of
thinking
• Same
things,
just
called
different
• MapView
is
deprecated
• MapFragment
for
new
development
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
20. • NaXve
Maps
applicaXon
• Street
View
• MapAcXvity
(deprecated)
• MapFragment
Support
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Mapping
Options
21. • Fragments
have
a
different
lifecycle
than
an
AcXvity
• Use
OnResume
• GoogleMapOpXons
• CameraPosiXon
• ZoomIn
• ZoomOut
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Using
the
MapFragment
22. • LocaXon
Manager.
• Hooks
to
LBS
Services.
• Current
LocaXon.
• Track
Movement.
• Proximity
Alerts.
• Interacts
with
LocaXon
Providers.
• LocaXon
Providers.
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Main
Location
Elements
23. • Permission.
• Which
Provider?
• Interface
–
ILocaXonListener.
• Implement
4
methods.
• Start
listening.
• Stop
listening
–
as
needed.
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Where
Am
I
24. • No
guarantee
of
any
provider.
• Take
advantage
of
new
providers.
• Only
need
certain
values.
• Accuracy.
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Criteria
25. • Example.
• Implement
ILocaXonListener.
• Methods
to
implement.
• Delivered
in
background
• Example
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Where
Am
I?
26. • Is
my
device
in
a
given
area?
• Crossing
a
boundary
• Similar
to
Regions
in
iOS
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Proximity
27. • Forward.
• Reverse.
• IList<Address>.
• Accuracy.
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Geocoding
28. • Intent
• Intent.AcXonView
• Parameters:
• geo:
• LaXtude
&
Longitude
• Zoom
level
• q
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Native
Maps
Application
29. • Intent
• Intent.AcXonView
• Parameters:
• LaXtude
• Longitude
• yaw/panorama
• pitch
• zoom
• mapZoom
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Street
View
30. Routing
• Examples
• iOS
• Android
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
31. Google
Maps
Setup
• Google
Maps
Key
• Xamarin
Component
Store
for
Bindings
• Google.Maps
namespace
• Apply
Key
• Set
bundle
idenXfier
in
Projects
• Add
Fragment
to
View
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.
32. • Somewhat
complicated
• Go
to
the
directory:
• Windows
Vista/7:
C:Users[USERNAME]AppDataLocal
XamarinMono
for
Android
• OSX:
/Users/[USERNAME]/.local/share/Xamarin/Mono
for
Android/
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Signing
Key
for
Mapping
33. • keytool.exe
-‐list
-‐alias
androiddebugkey
-‐keystore
debug.keystore
-‐storepass
android
-‐keypass
android
• Something
like
this
should
be
returned:
• androiddebugkey,
Aug
16,
2011,
PrivateKeyEntry,
CerXficate
fingerprint
(MD5):
AA:BB:CC:DD:EE:FF:
11:22:33:44:55:66:77:88:99:00
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Run
the
command
34. • Generate
Maps
API
Key
• h;p://code.google.com/android/maps-‐api-‐signup.html
• Note:
You
will
need
a
google
id
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Obtain
Maps
API
Key
35. • Your
map
key
• OpenGL
• Internet
• LocaXon
(Fine
implies
Coarse)
Copyright
2012,
Scalable
Development,
Inc.
All
Rights
Reserved
Manifest
File
36. Summary
&
Questions
• Maps
• Points
on
a
map
• Overlays
• Geocoding
• LocaXon
Management
• Power
Management
Copyright
2013,
Scalable
Development,
Inc.
All
Rights
Reserved.