Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Mapping With Xamarin

SmartyP
January 20, 2015

Mapping With Xamarin

An overview presentation on working with mapping controls with Xamarin.Android, Xamarin.iOS, and Xamarin.Forms.

SmartyP

January 20, 2015
Tweet

More Decks by SmartyP

Other Decks in Programming

Transcript

  1. MAPPING WITH Presented by Roger Peters   Virtual Xamarin Users

    Group   January 20th, 2015 XAMARIN h#ps://github.com/SmartyP/xamarin-­‐mapping-­‐sample-­‐apps
  2. ALL MOBILE Roger Peters (@SmartyP)   Independent Mobile Developer  

    AllMobileEverything.com   SmartyPantsCoding.com   SmartyP.net EVERYTHING
  3. To Embed or Not to Embed • What are you

    mapping? (Points, Regions, etc.) • How many items are you mapping? • What functionality does your user need/expect? • Time / Effort considerations
  4. Android Mapping Basics • Launch Google Maps • Embed Google

    Maps • Embed 3rd Party Map control (Bing, TomTom, etc.)* * not covered here
  5. Launch Map Activity Open Google Maps to GPS coordinate Open

    Google Maps to Street View Reference: h#p://developer.xamarin.com/guides/android/pla>orm_features/ maps_and_locaAon/maps/part_1_-­‐_maps_applicaAon/
  6. Setup Your App for Google Maps • Generate a SHA1

    fingerprint from signing .keystore • Get a Google Maps API key • Add API key to AndroidManifest.xml • Add permissions for INTERNET, ACCESS_NETWORK_STATE, and WRITE_EXTERNAL_STORAGE, etc. ref:     h#ps://code.google.com/apis/console/   h#ps://developers.google.com/maps/documentaAon/android/start#obtain_a_google_maps_api_key
  7. Embed Google Maps API v2 (cont’d) Reference: h#p://developer.xamarin.com/guides/android/pla>orm_features/maps_and_locaAon/maps/ part_2_-­‐_maps_api/ Common

    GoogleMap methods and properties: • MapType (Normal, Satellite, Hybrid, Terrain) • MoveCamera • Markers, Overlays
  8. iOS Mapping Basics • Launch Maps app • Embed Mapkit

    control • Embed 3rd party map control (Google Maps, etc.)* * not covered here
  9. Embed MapKit Control References: h#p://developer.xamarin.com/guides/ios/pla>orm_features/ios_maps/   h#p://developer.xamarin.com/guides/ios/pla>orm_features/ios_maps_walkthrough/   h#p://developer.xamarin.com/recipes/ios/content_controls/map_view/add_an_overlay_to_a_map/ Create

    MKMapView in code (or Storyboard): Common MKMapView methods and properties: • MapType (Standard, Satellite, Hybrid) • ZoomEnabled, ScrollEnabled • ShowUserLocation • Annotations, Overlays
  10. Setup Your App for MapKit • Update info.plist to include

    NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription strings • Call RequestWhenInUseAuthorization() on startup Note: new requirements for iOS8+
  11. Xamarin.Forms Mapping Basics • Launch native mapping app (ref: platform

    examples) • Embed Xamarin.Forms Map control • Embed 3rd party map controls (ArcGIS, etc.)* * would likely require creating custom renderer wrappers per platform
  12. Per Platform Setup iOS - Must add 2 text strings

    to Info.plist for iOS8+ Android - Must include Google Maps API key in AndroidManifest.xml and include app permissions Windows Phone - Must add needed capabilities to WMAppManifest.xml Reference: h#p://developer.xamarin.com/guides/cross-­‐pla>orm/xamarin-­‐forms/working-­‐with/maps/
  13. Advanced Maps - Marker Clustering References: h#ps://developers.google.com/maps/documentaAon/android/uAlity/marker-­‐clustering   h#p://robots.thoughtbot.com/how-­‐to-­‐handle-­‐large-­‐amounts-­‐of-­‐data-­‐on-­‐maps  

    h#p://blogs.msdn.com/b/bingdevcenter/archive/2013/10/15/clustering-­‐pushpins-­‐in-­‐windows-­‐store-­‐apps.aspx Grouping large numbers of markers into group markers to avoid plotting thousands of items each draw call. Included in Google Maps Android API Utility Library. Create your own on other platforms.
  14. Mapping With Xamarin Summary • Each approach requires some level

    of setup • There is variance in capabilities between mapping platforms • Xamarin.Forms.Maps provides cross-platform approach with common map functions
  15. ALL MOBILE Roger Peters (@SmartyP)   Independent Mobile Developer  

    AllMobileEverything.com   SmartyPantsCoding.com   SmartyP.net EVERYTHING