html5-img
1 / 46

Windows Phone 8 Maps and Location Services

Windows Phone 8 Maps and Location Services. Adina Trufinescu Program Manager Windows Phone Developer Platform. Location Service APIs Map Control and Services Location Tracking in Background Fast Resume. Agenda. Location Service API. Location for Windows Phone 8.

Download Presentation

Windows Phone 8 Maps and Location Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Phone 8 Maps and Location Services Adina Trufinescu Program Manager Windows Phone Developer Platform

  2. Location Service APIs Map Control and Services Location Tracking in Background Fast Resume Agenda

  3. Location Service API

  4. Location for Windows Phone 8 Periodic and distance based tracking Desired accuracy in meters Single location request Caching and timeout Position source • Track location changes • Desired accuracy • Movement threshold • PositionChanged • StatusChanged • Start & Stop A-GPS Wi-fi Cell .Net APIs Windows Runtime APIs

  5. Location Tracking • private GeolocatortrackingGeolocator; • private TypedEventHandler<Geolocator, PositionChangedEventArgs> positionChangedHandler; • publicvoid StartTracking() • { • trackingGeolocator= new Geolocator(); • trackingGeolocator.MovementThreshold= 100; • // or • trackingGeolocator.ReportInterval = (uint)TimeSpan.FromSeconds(30).TotalMilliseconds; • positionChangedHandler= (geolocator, eventArgs) => {}; • trackingGeolocator.PositionChanged+= positionChangedHandler; • } • publicvoid StopTracking() • { • trackingGeolocator.PositionChanged-= positionChangedHandler; • }

  6. Single Location Request • publicasyncTask<Geocoordinate> GetSinglePositionAsync() • { • Geolocatorgeolocator = new Geolocator(); • geolocator.DesiredAccuracyInMeters = 10; • Geopositiongeoposition = awaitgeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), • TimeSpan.FromSeconds(30)); • return geoposition.Coordinate; • }

  7. Tips for Location Apps • Use single location request when you can • Leverage caching for faster results • Find the right tradeoff between accuracy and timeout • Is wifi on?

  8. Map Control and Services

  9. Windows Phone 8 Map Control • Nokia Mapping Data110+ Countries, vector maps, 3D landmarks, new map modes • Offline MapsDownloadable by users, MapsDownloader tasks expose download and update to developers • Map ControlSmooth interactions, lag-less overlays, rotation, pitch • Route DisplayEasy to display Route calculated via Maps Services

  10. Windows Phone Maps Services • GeocodingLatitude,Longitude to Address • Reverse Geocoding Address to Latitude,Longitude • RoutingRouteQuery, Route, RouteLeg, RouteManeuver

  11. Windows Phone Map and Services API Part of Windows Phone Toolkit MapsUserControl PushPin ToGeoCoordinate • ID_CAP_MAP and ID_CAP_LOCATION • Developer Token assigned • through Windows Phone • Developer Center Map Control & Service APIs .Net Map Toolkit Extensions

  12. Map Control and Services Demo Mike O’Malley Program Manager

  13. Windows Phone 7.x Maps API • Deprecated for Windows Phone 8 AppsBing Maps Control Bing Maps Task • Continue to use for 7.x apps

  14. Map Control and Services Takeaway • Map Control and Maps Services APIs powered by Nokia • Map Extensions Toolkit • Users can manage offline maps • Bing Map control is deprecated for 8.0

  15. Location Tracking in Background

  16. Location Tracking in Background • App manifest: • <defaultTaskName="_default"NavigationPage="MainPage.xaml" > • <BackgroundExecution> • <ExecutionTypeName="LocationTracking" /> • </BackgroundExecution> • </defaultTask> • Actively listen for location change events

  17. Background Execution Constraints • XAML apps only • A single Location Tracking App runs in the background • App runs with limited access to resources

  18. Resource Management • CPU allocation is capped at 10% • App has access to • Location • Audio\Speech • Network • Storage • Sensors • No access to Camera, Microphone • ShellToast and ShellTile.Update

  19. User Awareness and Control • ID_CAP_LOCATION • Users can close the running app • Users can disable background • functionality per app

  20. Deactivation • App runs in the background until: • App stops tracking location • User disables Location Services • 4 hours without bringing the app in the foreground • Battery Saver ON • Another Location Tracking app moves to background • Low memory • DeactivationReason provided • Notify the user!

  21. Location Tracking in Background Demo

  22. App Lifecycle Events • PhoneApplicationService Launching Deactivated RunningInBackground Activated Closed

  23. Application Lifecycle Activated Deactivated tombstoned deactivated

  24. Application Lifecycle for Location Tracking Activated RunningInBg tombstoned deactivated

  25. Application Lifecycle – Launching&Closing Not Running Closing Launching Running Launching Launching Closing Running in Background

  26. Application Lifecycle – Launching&Closing Not Running Closing Launching Running Launching Launching Closing RunningInBg Closing Running in Background

  27. Tips for Running in Background Use sound and toasts wisely Inform the user when the app was deactivated Stop active timers and animations Stop tracking location when done Optimize for Fast Resume

  28. What is Fast Resume?

  29. Fast Resume for Windows Phone 8 Apps • “Replace” is the default activation policy • Opt-in to “Resume" via manifest setting • <defaultTaskName ="_default"NavigationPage="MainPage.xaml" • ActivationPolicy="Resume"/> • Apps are still suspended or tombstoned

  30. Fast Resume UX • Resume previous experience for Primary tile • when previously launched via Primary tile • Start fresh for Deep Links • when previously launched via Primary tile or a different Deep Link • Don’t block OnBackKeyPress • this is how users close your app

  31. Backstack – Do nothing

  32. Backstack – Clear page stack

  33. Backstack – Clear page stack Reset: Clear the page stack

  34. Backstack - Cancel navigation

  35. Backstack - Cancel navigation Reset: Cancel navigation

  36. Navigation Events • NavigationMode.Reset • raised on page at the top of the backstack; indicates that the app is relaunched • NavigationMode.New • raised when a page is created for new launch Uri • NavigationMode.Refresh • raised when launch Uri is same as the page at the top of the backstack

  37. NavigationMode.Reset Clear Page Stack Cancel Navigation NavigationMode.New Top Page OnNavigatedTo Top Page OnNavigatedFrom New Page OnNavigatingTo NavigationMode.Reset NavigationMode.New

  38. NavigationMode.Reset - Resume Cancel Navigation NavigationMode.New Top Page OnNavigatedTo Top Page OnNavigatedFrom Top Page Resume!!! NavigationMode.Reset

  39. NavigationMode.Reset – Start Fresh Clear Page Stack NavigationMode.New Top Page OnNavigatedTo Top Page OnNavigatedFrom New Page OnNavigatingTo NavigationMode.Reset NavigationMode.New

  40. Fast Resume Demo

  41. Fast Resume Takeaway • Main Tile: Resume! • Deep Links: Clear the back stack • OnBackKeyPress: Do not block • Test relaunch: between primary tile and deep links • Don’t forget Tombstoning!

  42. In Conclusion…

  43. Take Away • Map Control and Map Services powered by Nokia • Windows Runtime Location APIs • Background Execution for Location Tracking Apps • Want to resume fast? Use Fast Resume! 

  44. Resources • Maps Toolkit Extension @ • http://phone.codeplex.com • App to App Communication Session

  45. Questions?

More Related