Mapping on iOS and Android, Wally McClure
-
Upload
xamarin -
Category
Technology
-
view
1.081 -
download
3
Transcript of Mapping on iOS and Android, Wally McClure
![Page 1: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/1.jpg)
Location Based Services and Mapping with iOS
Wallace B. McClure Scalable Development, Inc.
Twi;er: @wbm Email: [email protected]
Phone: 865-‐740-‐3004
Copyrig
ht 2013, Scalable De
velopm
ent,
Inc. All Rights Reserved.
![Page 2: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/2.jpg)
Me.About() • Wally McClure • Scalable Development, Inc. • MicrosoQ ASP.NET MVP • ASPInsider • Legend in his own mind • Author • Scalable Development, Inc. • [email protected] • 865-‐740-‐3004 • Twi;er, Facebook, LinkedIn, …
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 3: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/3.jpg)
Agenda – Mapping in iOS • LocaXon Based Services • Apple Maps • Mapping with Android • Google Maps for iOS SDK – Sample Code
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 4: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/4.jpg)
Determine Location • GPS • Cellular TriangulaXon • Wifi lookup
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 5: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/5.jpg)
Namespaces • MapKit • Apple Framework for Mapping • MonoTouch.MapKit.MKMapView class
• CoreLocaXon • Apple Framework for LocaXon Services • MonoTouch.CoreLocaXon
• CLLocaXonManager • Points
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 6: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/6.jpg)
Displaying Maps • MapKit • LaXtude/Longitude • Center • Region to display • Google Maps uses ZoomLevel
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 7: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/7.jpg)
Map Properties • MKMapView • Region • Span • Center • ShowUserLocaXon • MapType
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 8: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/8.jpg)
Annotating Maps • Points on a map • Inherit – MKAnnotaXon • Point • Title • Overlays • Add/Remove
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 9: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/9.jpg)
Displaying Overlays • Shapes • Colors • Ex: 5 km gray circle • Standard Shapes • Custom
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 10: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/10.jpg)
Map Movement • Map Delegate • Inherit from MKMapViewDelegate • Region Changed Override • Communicate back to the parent • Example Now
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 11: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/11.jpg)
Location and Change Events • LocaXon changes • StartLocaXonChanges() • StartMonitoringSignificantLocaXonChanges() • UpdatedLocaXons Event • StartUpdaXngHeading()
• Choose the right mechanism • Be a good ciXzen on the device
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 12: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/12.jpg)
Background Processing -‐ Info.plist
• Requires locaXon service • Availability of locaXon services
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 13: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/13.jpg)
Region Monitoring • Need: • Point/Center • Radius
• Check when device crosses a boundary • IdenXfier
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 14: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/14.jpg)
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
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 15: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/15.jpg)
Geocoding • Forward • Reverse • Network connecXon
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 16: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/16.jpg)
Forward Geocoding (iOS5) • LocaXon -‐> lat/lon pair • Not in iOS 3 or 4 • In iOS 5+! • CLGeocoder • .GeocodeAddress • Async!
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 17: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/17.jpg)
Reverse Geocoding • BuilXn • Lat/Lon -‐> Address • Built in • Async • Network connecXon • Examples in Forward and Reverse
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 18: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/18.jpg)
But Apple Maps Has Problems • Google Maps for iOS SDK • Xamarin.iOS bindings
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 19: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/19.jpg)
Switch to Android • Different ways of thinking • Same things, just called different • MapView is deprecated • MapFragment for new development
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 20: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/20.jpg)
• NaXve Maps applicaXon • Street View • MapAcXvity (deprecated) • MapFragment Support
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Mapping Options
![Page 21: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/21.jpg)
• Fragments have a different lifecycle than an AcXvity • Use OnResume • GoogleMapOpXons • CameraPosiXon • ZoomIn • ZoomOut
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Using the MapFragment
![Page 22: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/22.jpg)
• LocaXon Manager. • Hooks to LBS Services. • Current LocaXon. • Track Movement. • Proximity Alerts. • Interacts with LocaXon Providers.
• LocaXon Providers.
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Main Location Elements
![Page 23: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/23.jpg)
• Permission. • Which Provider? • Interface – ILocaXonListener. • Implement 4 methods. • Start listening. • Stop listening – as needed.
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Where Am I
![Page 24: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/24.jpg)
• No guarantee of any provider. • Take advantage of new providers. • Only need certain values. • Accuracy.
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Criteria
![Page 25: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/25.jpg)
• Example. • Implement ILocaXonListener. • Methods to implement. • Delivered in background • Example
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Where Am I?
![Page 26: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/26.jpg)
• Is my device in a given area? • Crossing a boundary • Similar to Regions in iOS
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Proximity
![Page 27: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/27.jpg)
• Forward. • Reverse. • IList<Address>. • Accuracy.
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Geocoding
![Page 28: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/28.jpg)
• Intent • Intent.AcXonView • Parameters: • geo: • LaXtude & Longitude • Zoom level • q
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Native Maps Application
![Page 29: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/29.jpg)
• Intent • Intent.AcXonView • Parameters: • LaXtude • Longitude • yaw/panorama • pitch • zoom • mapZoom Co
pyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Street View
![Page 30: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/30.jpg)
Routing • Examples • iOS • Android
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 31: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/31.jpg)
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
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.
![Page 32: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/32.jpg)
• Somewhat complicated • Go to the directory: • Windows Vista/7: C:\Users\[USERNAME]\AppData\Local\Xamarin\Mono for Android\
• OSX: /Users/[USERNAME]/.local/share/Xamarin/Mono for Android/
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Signing Key for Mapping
![Page 33: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/33.jpg)
• 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
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Run the command
![Page 34: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/34.jpg)
• Generate Maps API Key • h;p://code.google.com/android/maps-‐api-‐signup.html • Note: You will need a google id
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Obtain Maps API Key
![Page 35: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/35.jpg)
• Your map key • OpenGL • Internet • LocaXon (Fine implies Coarse)
Copyrig
ht 2012, Scalable
Developm
ent, Inc. All Rights
Reserved
Manifest File
![Page 36: Mapping on iOS and Android, Wally McClure](https://reader033.fdocuments.net/reader033/viewer/2022042700/555ac6ead8b42ab1128b50ee/html5/thumbnails/36.jpg)
Summary & Questions • Maps • Points on a map • Overlays • Geocoding • LocaXon Management • Power Management
Copyrig
ht 2013, Scalable
Developm
ent, Inc. All Rights
Reserved
.