Location	  Based	  Services	  and	  Mapping	  with	  iOS	  Wallace	  B.	  McClure	  Scalable	  Development,	  Inc.	  Twi;e...
Me.About()	  •  Wally	  McClure	  •  Scalable	  Development,	  Inc.	  •  MicrosoQ	  ASP.NET	  MVP	  •  ASPInsider	  •  Leg...
Agenda	  –	  Mapping	  in	  iOS	  •  LocaXon	  Based	  Services	  •  Apple	  Maps	  •  Mapping	  with	  Android	  •  Googl...
Determine	  Location	  •  GPS	  •  Cellular	  TriangulaXon	  •  Wifi	  lookup	  Copyright	  2013,	  Scalable	  Development,...
Namespaces	  •  MapKit	  •  Apple	  Framework	  for	  Mapping	  •  MonoTouch.MapKit.MKMapView	  class	  •  CoreLocaXon	  •...
Displaying	  Maps	  •  MapKit	  •  LaXtude/Longitude	  •  Center	  •  Region	  to	  display	  •  Google	  Maps	  uses	  Zo...
Map	  Properties	  •  MKMapView	  •  Region	  •  Span	  •  Center	  •  ShowUserLocaXon	  •  MapType	  Copyright	  2013,	  ...
Annotating	  Maps	  •  Points	  on	  a	  map	  •  Inherit	  –	  MKAnnotaXon	  •  Point	  •  Title	  •  Overlays	  •  Add/R...
Displaying	  Overlays	  •  Shapes	  •  Colors	  •  Ex:	  5	  km	  gray	  circle	  •  Standard	  Shapes	  •  Custom	  Copyr...
Map	  Movement	  •  Map	  Delegate	  •  Inherit	  from	  MKMapViewDelegate	  •  Region	  Changed	  Override	  •  Communica...
Location	  and	  Change	  Events	  •  LocaXon	  changes	  •  StartLocaXonChanges()	  •  StartMonitoringSignificantLocaXonCh...
Background	  Processing	  -­‐	  Info.plist	  •  Requires	  locaXon	  service	  •  Availability	  of	  locaXon	  services	 ...
Region	  Monitoring	  •  Need:	  •  Point/Center	  •  Radius	  •  Check	  when	  device	  crosses	  a	  boundary	  •  Iden...
Tips	  for	  Conserving	  Battery	  •  Turn	  off	  locaXon	  services	  when	  not	  used	  •  Use	  the	  significant	  ch...
Geocoding	  •  Forward	  •  Reverse	  •  Network	  connecXon	  Copyright	  2013,	  Scalable	  Development,	  Inc.	  	  	  ...
Forward	  Geocoding	  (iOS5)	  •  LocaXon	  -­‐>	  lat/lon	  pair	  •  Not	  in	  iOS	  3	  or	  4	  •  In	  iOS	  5+!	  •...
Reverse	  Geocoding	  •  BuilXn	  •  Lat/Lon	  -­‐>	  Address	  •  Built	  in	  •  Async	  •  Network	  connecXon	  •  Exa...
But	  Apple	  Maps	  Has	  Problems	  •  Google	  Maps	  for	  iOS	  SDK	  •  Xamarin.iOS	  bindings	  Copyright	  2013,	 ...
Switch	  to	  Android	  •  Different	  ways	  of	  thinking	  •  Same	  things,	  just	  called	  different	  •  MapView	  i...
•  NaXve	  Maps	  applicaXon	  •  Street	  View	  •  MapAcXvity	  (deprecated)	  •  MapFragment	  Support	  Copyright	  20...
•  Fragments	  have	  a	  different	  lifecycle	  than	  an	  AcXvity	  •  Use	  OnResume	  •  GoogleMapOpXons	  •  CameraP...
•  LocaXon	  Manager.	  •  Hooks	  to	  LBS	  Services.	  •  Current	  LocaXon.	  •  Track	  Movement.	  •  Proximity	  Al...
•  Permission.	  •  Which	  Provider?	  •  Interface	  –	  ILocaXonListener.	  •  Implement	  4	  methods.	  •  Start	  li...
•  No	  guarantee	  of	  any	  provider.	  •  Take	  advantage	  of	  new	  providers.	  •  Only	  need	  certain	  values...
•  Example.	  •  Implement	  ILocaXonListener.	  •  Methods	  to	  implement.	  •  Delivered	  in	  background	  •  Exampl...
•  Is	  my	  device	  in	  a	  given	  area?	  •  Crossing	  a	  boundary	  •  Similar	  to	  Regions	  in	  iOS	  Copyrig...
•  Forward.	  •  Reverse.	  •  IList<Address>.	  •  Accuracy.	  Copyright	  2012,	  Scalable	  Development,	  Inc.	  All	 ...
•  Intent	  •  Intent.AcXonView	  •  Parameters:	  •  geo:	  •  LaXtude	  &	  Longitude	  •  Zoom	  level	  •  q	  Copyrig...
•  Intent	  •  Intent.AcXonView	  •  Parameters:	  •  LaXtude	  •  Longitude	  •  yaw/panorama	  •  pitch	  •  zoom	  •  m...
Routing	  •  Examples	  •  iOS	  •  Android	  Copyright	  2013,	  Scalable	  Development,	  Inc.	  	  	  	  All	  Rights	 ...
Google	  Maps	  Setup	  •  Google	  Maps	  Key	  •  Xamarin	  Component	  Store	  for	  Bindings	  •  Google.Maps	  namesp...
•  Somewhat	  complicated	  •  Go	  to	  the	  directory:	  •  Windows	  Vista/7:	  C:Users[USERNAME]AppDataLocalXamarinMo...
•  keytool.exe	  -­‐list	  -­‐alias	  androiddebugkey	  -­‐keystore	  debug.keystore	  -­‐storepass	  android	  -­‐keypass...
•  Generate	  Maps	  API	  Key	  •  h;p://code.google.com/android/maps-­‐api-­‐signup.html	  •  Note:	  You	  will	  need	...
•  Your	  map	  key	  •  OpenGL	  •  Internet	  •  LocaXon	  (Fine	  implies	  Coarse)	  Copyright	  2012,	  Scalable	  De...
Summary	  &	  Questions	  •  Maps	  •  Points	  on	  a	  map	  •  Overlays	  •  Geocoding	  •  LocaXon	  Management	  •  P...
Upcoming SlideShare
Loading in …5
×

Mapping on iOS and Android, Wally McClure

1,689 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,689
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
34
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mapping on iOS and Android, Wally McClure

  1. 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. 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. 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. 4. Determine  Location  •  GPS  •  Cellular  TriangulaXon  •  Wifi  lookup  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  5. 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. 6. Displaying  Maps  •  MapKit  •  LaXtude/Longitude  •  Center  •  Region  to  display  •  Google  Maps  uses  ZoomLevel  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  7. 7. Map  Properties  •  MKMapView  •  Region  •  Span  •  Center  •  ShowUserLocaXon  •  MapType  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  8. 8. Annotating  Maps  •  Points  on  a  map  •  Inherit  –  MKAnnotaXon  •  Point  •  Title  •  Overlays  •  Add/Remove  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  9. 9. Displaying  Overlays  •  Shapes  •  Colors  •  Ex:  5  km  gray  circle  •  Standard  Shapes  •  Custom  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  10. 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. 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. 12. Background  Processing  -­‐  Info.plist  •  Requires  locaXon  service  •  Availability  of  locaXon  services  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  13. 13. Region  Monitoring  •  Need:  •  Point/Center  •  Radius  •  Check  when  device  crosses  a  boundary  •  IdenXfier  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  14. 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. 15. Geocoding  •  Forward  •  Reverse  •  Network  connecXon  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  16. 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. 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. 18. But  Apple  Maps  Has  Problems  •  Google  Maps  for  iOS  SDK  •  Xamarin.iOS  bindings  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  19. 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. 20. •  NaXve  Maps  applicaXon  •  Street  View  •  MapAcXvity  (deprecated)  •  MapFragment  Support  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Mapping  Options  
  21. 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. 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. 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. 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. 25. •  Example.  •  Implement  ILocaXonListener.  •  Methods  to  implement.  •  Delivered  in  background  •  Example  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Where  Am  I?  
  26. 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. 27. •  Forward.  •  Reverse.  •  IList<Address>.  •  Accuracy.  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Geocoding  
  28. 28. •  Intent  •  Intent.AcXonView  •  Parameters:  •  geo:  •  LaXtude  &  Longitude  •  Zoom  level  •  q  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Native  Maps  Application  
  29. 29. •  Intent  •  Intent.AcXonView  •  Parameters:  •  LaXtude  •  Longitude  •  yaw/panorama  •  pitch  •  zoom  •  mapZoom  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Street  View  
  30. 30. Routing  •  Examples  •  iOS  •  Android  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  
  31. 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. 32. •  Somewhat  complicated  •  Go  to  the  directory:  •  Windows  Vista/7:  C:Users[USERNAME]AppDataLocalXamarinMono  for  Android  •  OSX:  /Users/[USERNAME]/.local/share/Xamarin/Mono  for  Android/  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Signing  Key  for  Mapping  
  33. 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. 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. 35. •  Your  map  key  •  OpenGL  •  Internet  •  LocaXon  (Fine  implies  Coarse)  Copyright  2012,  Scalable  Development,  Inc.  All  Rights  Reserved  Manifest  File  
  36. 36. Summary  &  Questions  •  Maps  •  Points  on  a  map  •  Overlays  •  Geocoding  •  LocaXon  Management  •  Power  Management  Copyright  2013,  Scalable  Development,  Inc.        All  Rights  Reserved.  

×