SlideShare a Scribd company logo
1 of 47
Download to read offline
Location and Maps
Nguyen Tuan | Microsoft Certified Trainer
Agenda
 RuntimeLocation API
 Current Location
 How to Continuously Track the Phone’s Location
 How to Run Location-TrackingApps in the Background
 How to use Map Control
 Specifying Map Center and Zoom
 Animating Map Display Using Map Views
8/16/2014 3
WP Runtime
Location API
Location APIs on Windows Phone 8
• .NET Location API from Windows Phone OS 7.1 is still
supported
• System.Device.Location.GeoCoordinateWatcher and related
classes
• New Windows Phone Runtime location API
• Accessible from managed and native code
• Improved ability for one-shot location acquisition
• Improved capabilities for location tracking
• Convergent with Windows 8 location API
ID_CAP_LOCATION Capability
• You must include the ID_CAP_LOCATION capability in your app
manifest
• If you forget, calls to location APIs throw an
UnauthorizedAccessException
8/16/2014 5
Location Sources
Location
Services
+ Accuracy
- Power
- Speed
- Indoors
- Accuracy
+ Power
+ Speed
- Wilderness
+/- Accuracy
+/- Power
+/- Speed
+/- Urban areas
GPS
Cell Towers
WiFi
• You can’t!
• You can set the DesiredAccuracyproperty of the Geolocator object:
• PositionAccuracy.High – if you want the most accurate data available, but at the cost of increased
battery usage, network bandwidth and possibly monetary charges from wireless network operators.
Often this causes the GPS to be activated
• PositionAccuracy.Default – to optimize for power
• You can also set the DesiredAccuracyInMeters property to indicate to
the Geolocation service the desired accuracy of any results
• However, the Geolocation service determines the best location data to
provide to the application
Controlling the Sources the Geolocation Service Uses
8/16/2014 ‹#›
How to Get the Phone’s Current Location
private async void OneShotLocation_Click(object sender, RoutedEventArgs e)
{
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 50;
try
{
Geoposition geoposition = await geolocator.GetGeopositionAsync(
maximumAge: TimeSpan.FromMinutes(5),
timeout: TimeSpan.FromSeconds(10)
);
LatitudeTextBlock.Text = geoposition.Coordinate.Latitude.ToString("0.00");
LongitudeTextBlock.Text = geoposition.Coordinate.Longitude.ToString("0.00");
}
catch (UnauthorizedAccessException)
{
// the app does not have the right capability or the location master switch is off
StatusTextBlock.Text = "location is disabled in phone settings.";
}
}
User Consent
• Application certification requirements on user consent still the same
as in 7.1
• If you are using location data just within your app, you do not need to
ask explicitly for user consent (although they give consent when they
install your app)
• You only have to get user consent if you plan to make location data
available to any other service or other person:
2.7.4 If your application publishes or makes available location data obtained from the Location ServiceAPI to
any other service or other person (including advertising networks), your application must implement a method to
obtain opt-in consent. …
8/16/2014 9
• Windows Phone Emulator comes with Location simulator
Location on Emulator
10
• If your app only needs the user’s location at
the current time, use GetGeopositionAsync
as already described
• Continuously tracking the user’s location
drains the user’s battery more and should
only be used for apps that require it
Location Tracking
8/16/2014 11
private void TrackLocation_Click(object sender, RoutedEventArgs e)
{
if (!tracking) {
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.MovementThreshold = 100; // The units are meters.
geolocator.StatusChanged += geolocator_StatusChanged;
geolocator.PositionChanged += geolocator_PositionChanged;
tracking = true;
}
else {
geolocator.PositionChanged -= geolocator_PositionChanged;
geolocator.StatusChanged -= geolocator_StatusChanged;
geolocator = null;
tracking = false;
}
}
How to Track Location
8/16/2014
void geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
{
string status = "";
switch (args.Status)
{
case PositionStatus.Disabled:
// the application does not have the right capability or the location master switch is off
status = "location is disabled in phone settings";
break;
case PositionStatus.Initializing:
// the geolocator started the tracking operation
status = "initializing";
break;
case PositionStatus.NoData:
// the location service was not able to acquire the location
status = "no data";
break;
Geolocator Status
8/16/2014 13
void geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
{
string status = "";
switch (args.Status)
{
case PositionStatus.Disabled:
// the application does not have the right capability or the location master
switch is off
status = "location is disabled in phone settings";
break;
case PositionStatus.Initializing:
// the geolocator started the tracking operation
status = "initializing";
break;
case PositionStatus.NoData:
// the location service was not able to acquire the location
status = "no data";
break;
case PositionStatus.Ready:
// the location service is generating geopositions as specified by the
tracking parameters
Geolocator Status
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs
args)
{
Dispatcher.BeginInvoke(() =>
{
LatitudeTextBlock.Text =
args.Position.Coordinate.Latitude.ToString("0.00");
LongitudeTextBlock.Text =
args.Position.Coordinate.Longitude.ToString("0.00");
});
}
Position Changed
8/16/2014 15
Demo
LocationTracker
16
• Normally, when your user navigates away from your app, it is made
dormant and all activity – includinglocation tracking – is suspended
• In Windows Phone 8, a location-trackingapp can continue to run in the
background after the user navigates away, as long as the app continues
to actively track location
• This feature enables scenarios such as an app that provides turn-by-turn
directions or a run tracker
Enable Location Tracking in the Background
8/16/2014 17
• Edit WMAppManifest.xml using the XML (Text) Editor
•Replace <DefaultTask> element as shown
Enable Background Execution
18
• In App.Xaml, register an event handler for the RunningInBackground
event
• This event is raised when the user navigates away from your background execution-enabled app while
you are actively tracking location
• When this event is raised, your app should stop all tasks that are not related to location tracking,
including updates to the app’s UI
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing“
Activated="Application_Activated" Deactivated="Application_Deactivated“
RunningInBackground="Application_RunningInBackground"/>
</Application.ApplicationLifetimeObjects>
Register Event Handler for RunningInBackground
Event
8/16/2014 19
// Static variables global to application to support tracking
public static Geolocator Geolocator { get; set; }
public static bool RunningInBackground { get; set; }
// Code to execute when the application is activated (brought to foreground)
private void Application_Activated(object sender, ActivatedEventArgs e)
{
RunningInBackground = false;
}
// Code to execute when the application is deactivated and is tracking location
private void Application_RunningInBackground(object sender, RunningInBackgroundEventArgs e)
{
RunningInBackground = true;
// Suspend all unnecessary processing such as UI updates
}
Implement RunningInBackground Event Handler
8/16/2014 20
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
if (!App.RunningInBackground)
{
Dispatcher.BeginInvoke(() => {
LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00");
LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00"); });
}
else
{ // DEMO purposes only: Show toast if running in background
Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
toast.Content = args.Position.Coordinate.Latitude.ToString("0.00");
toast.Title = "Location: ";
toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative);
toast.Show();
}
}
Do Not Update UI When Running in the Background
Example
• As we have seen, Background Location Tracking apps continue to run in the
background
• But if it is not actively tracking location when deactivated, it is made dormant as normal
• If the user launches *another* location tracking app and deactivates that, then your app will be made dormant
• If the user launches a new instance of the app, if there is a dormant instance,
that is reactivated instead
• Background Location Tracking apps get the Fast Application Resume behavior, which reactivates a dormant
application if the user launches a new copy
• The dormant instance of the app, including the history of visited app pages, is reactivated
• By default, the list of previously visited pages is cleared for these ‘Reset’
activations
• This may not be what you want…
App Lifecycle for Background Location Tracking Apps
Fast Application Resume
8/16/2014 22
private void InitializePhoneApplication()
{
...
// Handle reset requests for clearing the backstack
RootFrame.Navigated += CheckForResetNavigation;
...
}
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
{
// If the app has received a 'reset' navigation, then we need to check
// on the next navigation to see if the page stack should be reset
if (e.NavigationMode == NavigationMode.Reset)
RootFrame.Navigated += ClearBackStackAfterReset;
}
Clearing Previously Launched Pages on Fast App
Resume
Add Logic to App.Xaml.cs to Check for Reset Navigation(Behavior Already Implemented in Project Templates)
8/16/2014 23
private void InitializePhoneApplication()
{
...
// Handle reset requests for clearing the backstack
RootFrame.Navigated += CheckForResetNavigation;
...
}
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
{
// If the app has received a 'reset' navigation, then we need to check
// on the next navigation to see if the page stack should be reset
if (e.NavigationMode == NavigationMode.Reset)
RootFrame.Navigated += ClearBackStackAfterReset;
}
private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
{
// Unregister the event so it doesn't get called again
RootFrame.Navigated -= ClearBackStackAfterReset;
// Only clear the stack for 'new' (forward) and 'refresh' navigations
if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
return;
// For UI consistency, clear the entire page stack
while (RootFrame.RemoveBackEntry() != null) { } // do nothing
}
Clearing Previously Launched Pages on Fast App
Resume
Add Logic to App.Xaml.cs to Check for Reset Navigation(Behavior Already Implemented in Project Templates)
8/16/2014 24
Demo
BackgroundLocationTracker
Maps
Maps APIs on Windows Phone 8
• Windows Phone 8 has new Map controls, accessible in
the following namespaces:
• Microsoft.Phone.Maps
• Microsoft.Phone.Maps.Controls
• Microsoft.Phone.Maps.Services
• The Bing Maps Control is still supported, but is
deprecated
• You should only use the Bing Maps Control when you upgrade
an app from Windows Phone OS 7.1 to Windows Phone 8
• Usage of the new Maps control differs from the Bing
Maps control
ID_CAP_MAP Capability
• You must include the ID_CAP_MAP capability in your app manifest
• If you forget, calls to location APIs throw an
UnauthorizedAccessException
8/16/2014 28
• Add a Map to your UI
•In XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<maps:Map x:Name="MyMap"/>
</Grid>
•In Code:
private void CreateMap()
{
Map MyMap = new Map();
ContentPanel.Children.Add(MyMap);
}
Map Control
• By default, map displays at zoom level
1 (world view) and centered at Lat: 0,
Long: 0
• Use the Center and ZoomLevel
properties to change this, in XAML or
in code
//Set the Map center by using Center property
MyMap.Center = new GeoCoordinate(47.6097, -
122.3331);
//Set the map zoom by using ZoomLevel property
MyMap.ZoomLevel = 10;
Center and Zoom Level
8/16/2014 30
• It is common to move a map display from one location to another
• A new map view is defined any time the position of the map is changed as a result of panning, zooming,
rotating, or tilting
• You can use the SetView method to define a map view.
This takes the following parameters:
• Center: A GeoCoordiante object defining the center of the map view
• ZoomLevel:zoom level between 1 and 20
• Heading: specifies the directional heading that is pointing “up” on the mapin geometric degrees between 0 and 360
• Pitch: specifies the degree to which the map is tilted as a value between 0 and 180
• BoundingRectangle:a LocationRectangle object that contains the Map control
• AnimationKind: sets the kind of animationyou want to see (None, Linear or Parabolic) when the view changes
MapViews
8/16/2014 31
• Set the cartographic mode of the map with the CartographicMode
property
Cartographic Mode
8/16/2014 32
Road (default) Aerial Hybrid Terrain
• You can display the map in a light or dark color mode by setting the
ColorMode property
Light and Dark Color Modes
8/16/2014 33
Light (default) Dark
• You can display additional elements on
your map, such as landmarks and
pedestrian features
•Set the LandmarksEnabled property to
true to display landmarks
•Set the PedestrianFeaturesEnabled to
true to display pedestrian features
• Landmarks are visible only when the
ZoomLevel is 7 or higher, and the Pitch
property is 25 or higher
Pedestrian Features and Landmarks
8/16/2014 34
Demo
1. BasicLocationandMap
2. MapViews
35
• Unlike the Bing Maps API, the Windows
Phone Maps API does not have a
specific PushPin object
• However, you can create your own
PushPins by drawing UIElements onto a
MapOverlay, then add the MapOverlay
to a MapLayer which you add to the
Map
Pushpins
8/16/2014 36
private Grid CreatePushpin()
{
//Creating a Grid element.
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
//Creating a Rectangle
Rectangle MyRectangle = new Rectangle();
MyRectangle.Fill = new SolidColorBrush(Colors.Black);
MyRectangle.Height = 20;
MyRectangle.Width = 20;
MyRectangle.SetValue(Grid.RowProperty, 0);
MyRectangle.SetValue(Grid.ColumnProperty, 0);
//Adding the Rectangle to the Grid
MyGrid.Children.Add(MyRectangle);
Creating a Pushpin
8/16/2014 37
private Grid CreatePushpin()
{
//Creating a Grid element.
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
//Creating a Rectangle
Rectangle MyRectangle = new Rectangle();
MyRectangle.Fill = new SolidColorBrush(Colors.Black);
MyRectangle.Height = 20;
MyRectangle.Width = 20;
MyRectangle.SetValue(Grid.RowProperty, 0);
MyRectangle.SetValue(Grid.ColumnProperty, 0);
//Adding the Rectangle to the Grid
MyGrid.Children.Add(MyRectangle);
Creating a Pushpin
8/16/2014 38
private void AddMapOverlay()
{
Grid MyGrid = CreatePushpin();
//Creating a MapOverlay and adding the Grid to it.
MapOverlay MyOverlay = new MapOverlay();
MyOverlay.Content = MyGrid;
MyOverlay.GeoCoordinate = new GeoCoordinate(47.6097, -122.3331);
MyOverlay.PositionOrigin = new Point(0, 0.5);
//Creating a MapLayer and adding the MapOverlay to it
MapLayer MyLayer = new MapLayer();
MyLayer.Add(MyOverlay);
MyMap.Layers.Add(MyLayer);
}
Drawing a UIElement onto a MapLayer
8/16/2014 39
Demo
LocationAndMaps
40
Maps Launchers
MapsTask
MapsTaskmakes launching the built-in Maps application easy
MapsTask mapsTask = new MapsTask();
//Omit the Center property to use the user's current location.
mapsTask.Center = new GeoCoordinate(47.6204, -122.3493);
mapsTask.SearchTerm = "coffee";
mapsTask.ZoomLevel = 17;
mapsTask.Show();
• Launchingbuilt-in Maps tasks with directions enabled is trivial too!
MapsDirectionsTask
43
// Get Directions
MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask();
// You can specify a label and a geocoordinate for the end point.
// GeoCoordinate spaceNeedleLocation = new GeoCoordinate(47.6204,-122.3493);
// LabeledMapLocation spaceNdleLML = new LabeledMapLocation("Space Needle",
spaceNeedleLocation);
// If you set the geocoordinate parameter to null, the label parameter
// is used as a search term.
LabeledMapLocation spaceNdleLML = new LabeledMapLocation("Space Needle", null);
// If mapsDirectionsTask.Start is not set, the user's current location
// is used as start point.
mapsDirectionsTask.End = spaceNdleLML;
mapsDirectionsTask.Show();
• Use the map downloader task to enable users to
download map data for offline use
• The task launches the Maps settings application
which allows the user to select a region of map data
to download
MapDownloaderTask
MapDownloaderTask mapDownloaderTask = new
MapDownloaderTask();
mapDownloaderTask.Show();
• Use the map updater task to enable users to update map data
they have previously downloaded for offline use
• The task launches the Maps settings application which
immediately checks to see if there are updates available for
any previously downloaded map data
MapUpdaterTask
MapUpdaterTask mapUpdaterTask = new MapUpdaterTask();
mapUpdaterTask.Show();
Demo
MapsTask
46
Summaries
• Windows Phone Runtime location API is new in Windows Phone 8. It
has the followingfeatures:
• Accessible from managed and native code
• Greater support for one-shot location acquisition
• Support for Background Location Tracking
• Convergent with Windows 8
• Use the new Maps APIs in Windows Phone 8 to develop maps-based
apps, and incorporate location and search features
• Set Center and Zoom Level
• Animate to new location and zoom using map views
• Select Road, Aerial, Hybrid or Terrain cartographic display modes
• Draw UIElements onto a MapOverlay on top of the Map

More Related Content

Viewers also liked

Информационный вестник Октябрь 2013
Информационный вестник Октябрь 2013 Информационный вестник Октябрь 2013
Информационный вестник Октябрь 2013 Ingria. Technopark St. Petersburg
 
2014 esc training presentation combined
2014 esc training presentation combined2014 esc training presentation combined
2014 esc training presentation combinedSelena Knight
 
Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011RipMedia Group,
 
Thriving in a Mobile Driven World
Thriving in a Mobile Driven WorldThriving in a Mobile Driven World
Thriving in a Mobile Driven Worldprnewswire
 
Kartagen4new
Kartagen4newKartagen4new
Kartagen4newOpanki Gm
 
Mobilizing Masses: Multimedia, Multichannel, MyFreeTaxes
Mobilizing Masses: Multimedia, Multichannel, MyFreeTaxesMobilizing Masses: Multimedia, Multichannel, MyFreeTaxes
Mobilizing Masses: Multimedia, Multichannel, MyFreeTaxesprnewswire
 
Web sémantique : données liées et sémantique des schémas
Web sémantique : données liées et sémantique des schémasWeb sémantique : données liées et sémantique des schémas
Web sémantique : données liées et sémantique des schémasguest008d8e
 
San Jose October 2009l
San  Jose  October 2009lSan  Jose  October 2009l
San Jose October 2009ldigitalschema
 
08.Push Notifications
08.Push Notifications 08.Push Notifications
08.Push Notifications Nguyen Tuan
 
Public Cloud - Add New Revenue & Profitability to Your Existing Hosting Business
Public Cloud - Add New Revenue & Profitability to Your Existing Hosting BusinessPublic Cloud - Add New Revenue & Profitability to Your Existing Hosting Business
Public Cloud - Add New Revenue & Profitability to Your Existing Hosting BusinessCraig Deveson
 
Fostering historical thinking with digitized primary sources
Fostering historical thinking with digitized primary sourcesFostering historical thinking with digitized primary sources
Fostering historical thinking with digitized primary sourcesOrna Farrell
 
Filpbook Powerpoint Ryerson
Filpbook Powerpoint RyersonFilpbook Powerpoint Ryerson
Filpbook Powerpoint RyersonRyersonC
 
Информационный вестник Сентябрь 2012
Информационный вестник Сентябрь 2012Информационный вестник Сентябрь 2012
Информационный вестник Сентябрь 2012Ingria. Technopark St. Petersburg
 

Viewers also liked (20)

Информационный вестник Октябрь 2013
Информационный вестник Октябрь 2013 Информационный вестник Октябрь 2013
Информационный вестник Октябрь 2013
 
2014 esc training presentation combined
2014 esc training presentation combined2014 esc training presentation combined
2014 esc training presentation combined
 
Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011
 
Thriving in a Mobile Driven World
Thriving in a Mobile Driven WorldThriving in a Mobile Driven World
Thriving in a Mobile Driven World
 
Kartagen4new
Kartagen4newKartagen4new
Kartagen4new
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
Mobilizing Masses: Multimedia, Multichannel, MyFreeTaxes
Mobilizing Masses: Multimedia, Multichannel, MyFreeTaxesMobilizing Masses: Multimedia, Multichannel, MyFreeTaxes
Mobilizing Masses: Multimedia, Multichannel, MyFreeTaxes
 
Elena
ElenaElena
Elena
 
Web sémantique : données liées et sémantique des schémas
Web sémantique : données liées et sémantique des schémasWeb sémantique : données liées et sémantique des schémas
Web sémantique : données liées et sémantique des schémas
 
San Jose October 2009l
San  Jose  October 2009lSan  Jose  October 2009l
San Jose October 2009l
 
Itec Workshop
Itec WorkshopItec Workshop
Itec Workshop
 
08.Push Notifications
08.Push Notifications 08.Push Notifications
08.Push Notifications
 
Cokecola
CokecolaCokecola
Cokecola
 
Public Cloud - Add New Revenue & Profitability to Your Existing Hosting Business
Public Cloud - Add New Revenue & Profitability to Your Existing Hosting BusinessPublic Cloud - Add New Revenue & Profitability to Your Existing Hosting Business
Public Cloud - Add New Revenue & Profitability to Your Existing Hosting Business
 
Fostering historical thinking with digitized primary sources
Fostering historical thinking with digitized primary sourcesFostering historical thinking with digitized primary sources
Fostering historical thinking with digitized primary sources
 
Career3
Career3Career3
Career3
 
Filpbook Powerpoint Ryerson
Filpbook Powerpoint RyersonFilpbook Powerpoint Ryerson
Filpbook Powerpoint Ryerson
 
Информационный вестник Сентябрь 2012
Информационный вестник Сентябрь 2012Информационный вестник Сентябрь 2012
Информационный вестник Сентябрь 2012
 
Google does 1916
Google does 1916Google does 1916
Google does 1916
 
Cpd 102 ab fall10session1
Cpd 102 ab fall10session1Cpd 102 ab fall10session1
Cpd 102 ab fall10session1
 

Similar to 12.Maps and Location

Windows Phone 8 - 15 Location and Maps
Windows Phone 8 - 15 Location and MapsWindows Phone 8 - 15 Location and Maps
Windows Phone 8 - 15 Location and MapsOliver Scheer
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesNick Landry
 
Windows Phone 8 Fundamental
Windows Phone 8 FundamentalWindows Phone 8 Fundamental
Windows Phone 8 FundamentalNguyên Phạm
 
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONELUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONEMicrosoft Mobile Developer
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 seriesopenbala
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native appsInnovationM
 
How to start a turn-by-turn navigation to a destination from your Windows Pho...
How to start a turn-by-turn navigation to a destination from your Windows Pho...How to start a turn-by-turn navigation to a destination from your Windows Pho...
How to start a turn-by-turn navigation to a destination from your Windows Pho...Enzo Contini
 
Android app performance
Android app performanceAndroid app performance
Android app performanceSaksham Keshri
 
20180823 警廣地圖APP開發與踩到的n個坑
20180823 警廣地圖APP開發與踩到的n個坑20180823 警廣地圖APP開發與踩到的n個坑
20180823 警廣地圖APP開發與踩到的n個坑Mark Chiu
 
20220816-GeolocationAPI-AdvancedWebDevelopment.pptx
20220816-GeolocationAPI-AdvancedWebDevelopment.pptx20220816-GeolocationAPI-AdvancedWebDevelopment.pptx
20220816-GeolocationAPI-AdvancedWebDevelopment.pptxSuman Garai
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 
Introduction to Struts
Introduction to StrutsIntroduction to Struts
Introduction to Strutselliando dias
 
CSE-4078 - Lecture - Week 10 -11aga.pptx
CSE-4078 - Lecture - Week 10 -11aga.pptxCSE-4078 - Lecture - Week 10 -11aga.pptx
CSE-4078 - Lecture - Week 10 -11aga.pptxzaidAhmad84
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Luc Bors
 

Similar to 12.Maps and Location (20)

Windows Phone 8 - 15 Location and Maps
Windows Phone 8 - 15 Location and MapsWindows Phone 8 - 15 Location and Maps
Windows Phone 8 - 15 Location and Maps
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location Services
 
Windows Phone 8 Fundamental
Windows Phone 8 FundamentalWindows Phone 8 Fundamental
Windows Phone 8 Fundamental
 
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONELUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
LUMIA APP LABS: HERE MAPS AND LOCATION APIS FOR WINDOWS PHONE
 
Core Location in iOS
Core Location in iOSCore Location in iOS
Core Location in iOS
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native apps
 
Html5 geolocation api
Html5 geolocation apiHtml5 geolocation api
Html5 geolocation api
 
How to start a turn-by-turn navigation to a destination from your Windows Pho...
How to start a turn-by-turn navigation to a destination from your Windows Pho...How to start a turn-by-turn navigation to a destination from your Windows Pho...
How to start a turn-by-turn navigation to a destination from your Windows Pho...
 
Tracking android apps
Tracking android appsTracking android apps
Tracking android apps
 
Android app performance
Android app performanceAndroid app performance
Android app performance
 
DIY Uber
DIY UberDIY Uber
DIY Uber
 
20180823 警廣地圖APP開發與踩到的n個坑
20180823 警廣地圖APP開發與踩到的n個坑20180823 警廣地圖APP開發與踩到的n個坑
20180823 警廣地圖APP開發與踩到的n個坑
 
20220816-GeolocationAPI-AdvancedWebDevelopment.pptx
20220816-GeolocationAPI-AdvancedWebDevelopment.pptx20220816-GeolocationAPI-AdvancedWebDevelopment.pptx
20220816-GeolocationAPI-AdvancedWebDevelopment.pptx
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Introduction to Struts
Introduction to StrutsIntroduction to Struts
Introduction to Struts
 
CSE-4078 - Lecture - Week 10 -11aga.pptx
CSE-4078 - Lecture - Week 10 -11aga.pptxCSE-4078 - Lecture - Week 10 -11aga.pptx
CSE-4078 - Lecture - Week 10 -11aga.pptx
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)
 
Struts Intro
Struts IntroStruts Intro
Struts Intro
 

More from Nguyen Tuan

07.Notifications & Reminder, Contact
07.Notifications & Reminder, Contact07.Notifications & Reminder, Contact
07.Notifications & Reminder, ContactNguyen Tuan
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) Nguyen Tuan
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQNguyen Tuan
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WPNguyen Tuan
 
13.Windows Phone Store
13.Windows Phone Store13.Windows Phone Store
13.Windows Phone StoreNguyen Tuan
 
06.Programming Media on Windows Phone
06.Programming Media on Windows Phone06.Programming Media on Windows Phone
06.Programming Media on Windows PhoneNguyen Tuan
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & AnimationNguyen Tuan
 
03.Controls in Windows Phone
03.Controls in Windows Phone03.Controls in Windows Phone
03.Controls in Windows PhoneNguyen Tuan
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows PhoneNguyen Tuan
 
02.Designing Windows Phone Application
02.Designing Windows Phone Application02.Designing Windows Phone Application
02.Designing Windows Phone ApplicationNguyen Tuan
 

More from Nguyen Tuan (10)

07.Notifications & Reminder, Contact
07.Notifications & Reminder, Contact07.Notifications & Reminder, Contact
07.Notifications & Reminder, Contact
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA)
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQ
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 
13.Windows Phone Store
13.Windows Phone Store13.Windows Phone Store
13.Windows Phone Store
 
06.Programming Media on Windows Phone
06.Programming Media on Windows Phone06.Programming Media on Windows Phone
06.Programming Media on Windows Phone
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
 
03.Controls in Windows Phone
03.Controls in Windows Phone03.Controls in Windows Phone
03.Controls in Windows Phone
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows Phone
 
02.Designing Windows Phone Application
02.Designing Windows Phone Application02.Designing Windows Phone Application
02.Designing Windows Phone Application
 

12.Maps and Location

  • 1. Location and Maps Nguyen Tuan | Microsoft Certified Trainer
  • 2. Agenda  RuntimeLocation API  Current Location  How to Continuously Track the Phone’s Location  How to Run Location-TrackingApps in the Background  How to use Map Control  Specifying Map Center and Zoom  Animating Map Display Using Map Views
  • 4. Location APIs on Windows Phone 8 • .NET Location API from Windows Phone OS 7.1 is still supported • System.Device.Location.GeoCoordinateWatcher and related classes • New Windows Phone Runtime location API • Accessible from managed and native code • Improved ability for one-shot location acquisition • Improved capabilities for location tracking • Convergent with Windows 8 location API
  • 5. ID_CAP_LOCATION Capability • You must include the ID_CAP_LOCATION capability in your app manifest • If you forget, calls to location APIs throw an UnauthorizedAccessException 8/16/2014 5
  • 6. Location Sources Location Services + Accuracy - Power - Speed - Indoors - Accuracy + Power + Speed - Wilderness +/- Accuracy +/- Power +/- Speed +/- Urban areas GPS Cell Towers WiFi
  • 7. • You can’t! • You can set the DesiredAccuracyproperty of the Geolocator object: • PositionAccuracy.High – if you want the most accurate data available, but at the cost of increased battery usage, network bandwidth and possibly monetary charges from wireless network operators. Often this causes the GPS to be activated • PositionAccuracy.Default – to optimize for power • You can also set the DesiredAccuracyInMeters property to indicate to the Geolocation service the desired accuracy of any results • However, the Geolocation service determines the best location data to provide to the application Controlling the Sources the Geolocation Service Uses 8/16/2014 ‹#›
  • 8. How to Get the Phone’s Current Location private async void OneShotLocation_Click(object sender, RoutedEventArgs e) { Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 50; try { Geoposition geoposition = await geolocator.GetGeopositionAsync( maximumAge: TimeSpan.FromMinutes(5), timeout: TimeSpan.FromSeconds(10) ); LatitudeTextBlock.Text = geoposition.Coordinate.Latitude.ToString("0.00"); LongitudeTextBlock.Text = geoposition.Coordinate.Longitude.ToString("0.00"); } catch (UnauthorizedAccessException) { // the app does not have the right capability or the location master switch is off StatusTextBlock.Text = "location is disabled in phone settings."; } }
  • 9. User Consent • Application certification requirements on user consent still the same as in 7.1 • If you are using location data just within your app, you do not need to ask explicitly for user consent (although they give consent when they install your app) • You only have to get user consent if you plan to make location data available to any other service or other person: 2.7.4 If your application publishes or makes available location data obtained from the Location ServiceAPI to any other service or other person (including advertising networks), your application must implement a method to obtain opt-in consent. … 8/16/2014 9
  • 10. • Windows Phone Emulator comes with Location simulator Location on Emulator 10
  • 11. • If your app only needs the user’s location at the current time, use GetGeopositionAsync as already described • Continuously tracking the user’s location drains the user’s battery more and should only be used for apps that require it Location Tracking 8/16/2014 11
  • 12. private void TrackLocation_Click(object sender, RoutedEventArgs e) { if (!tracking) { geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; geolocator.MovementThreshold = 100; // The units are meters. geolocator.StatusChanged += geolocator_StatusChanged; geolocator.PositionChanged += geolocator_PositionChanged; tracking = true; } else { geolocator.PositionChanged -= geolocator_PositionChanged; geolocator.StatusChanged -= geolocator_StatusChanged; geolocator = null; tracking = false; } } How to Track Location 8/16/2014
  • 13. void geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args) { string status = ""; switch (args.Status) { case PositionStatus.Disabled: // the application does not have the right capability or the location master switch is off status = "location is disabled in phone settings"; break; case PositionStatus.Initializing: // the geolocator started the tracking operation status = "initializing"; break; case PositionStatus.NoData: // the location service was not able to acquire the location status = "no data"; break; Geolocator Status 8/16/2014 13
  • 14. void geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args) { string status = ""; switch (args.Status) { case PositionStatus.Disabled: // the application does not have the right capability or the location master switch is off status = "location is disabled in phone settings"; break; case PositionStatus.Initializing: // the geolocator started the tracking operation status = "initializing"; break; case PositionStatus.NoData: // the location service was not able to acquire the location status = "no data"; break; case PositionStatus.Ready: // the location service is generating geopositions as specified by the tracking parameters Geolocator Status
  • 15. void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { Dispatcher.BeginInvoke(() => { LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00"); LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00"); }); } Position Changed 8/16/2014 15
  • 17. • Normally, when your user navigates away from your app, it is made dormant and all activity – includinglocation tracking – is suspended • In Windows Phone 8, a location-trackingapp can continue to run in the background after the user navigates away, as long as the app continues to actively track location • This feature enables scenarios such as an app that provides turn-by-turn directions or a run tracker Enable Location Tracking in the Background 8/16/2014 17
  • 18. • Edit WMAppManifest.xml using the XML (Text) Editor •Replace <DefaultTask> element as shown Enable Background Execution 18
  • 19. • In App.Xaml, register an event handler for the RunningInBackground event • This event is raised when the user navigates away from your background execution-enabled app while you are actively tracking location • When this event is raised, your app should stop all tasks that are not related to location tracking, including updates to the app’s UI <Application.ApplicationLifetimeObjects> <!--Required object that handles lifetime events for the application--> <shell:PhoneApplicationService Launching="Application_Launching" Closing="Application_Closing“ Activated="Application_Activated" Deactivated="Application_Deactivated“ RunningInBackground="Application_RunningInBackground"/> </Application.ApplicationLifetimeObjects> Register Event Handler for RunningInBackground Event 8/16/2014 19
  • 20. // Static variables global to application to support tracking public static Geolocator Geolocator { get; set; } public static bool RunningInBackground { get; set; } // Code to execute when the application is activated (brought to foreground) private void Application_Activated(object sender, ActivatedEventArgs e) { RunningInBackground = false; } // Code to execute when the application is deactivated and is tracking location private void Application_RunningInBackground(object sender, RunningInBackgroundEventArgs e) { RunningInBackground = true; // Suspend all unnecessary processing such as UI updates } Implement RunningInBackground Event Handler 8/16/2014 20
  • 21. void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { if (!App.RunningInBackground) { Dispatcher.BeginInvoke(() => { LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00"); LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00"); }); } else { // DEMO purposes only: Show toast if running in background Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast(); toast.Content = args.Position.Coordinate.Latitude.ToString("0.00"); toast.Title = "Location: "; toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative); toast.Show(); } } Do Not Update UI When Running in the Background Example
  • 22. • As we have seen, Background Location Tracking apps continue to run in the background • But if it is not actively tracking location when deactivated, it is made dormant as normal • If the user launches *another* location tracking app and deactivates that, then your app will be made dormant • If the user launches a new instance of the app, if there is a dormant instance, that is reactivated instead • Background Location Tracking apps get the Fast Application Resume behavior, which reactivates a dormant application if the user launches a new copy • The dormant instance of the app, including the history of visited app pages, is reactivated • By default, the list of previously visited pages is cleared for these ‘Reset’ activations • This may not be what you want… App Lifecycle for Background Location Tracking Apps Fast Application Resume 8/16/2014 22
  • 23. private void InitializePhoneApplication() { ... // Handle reset requests for clearing the backstack RootFrame.Navigated += CheckForResetNavigation; ... } private void CheckForResetNavigation(object sender, NavigationEventArgs e) { // If the app has received a 'reset' navigation, then we need to check // on the next navigation to see if the page stack should be reset if (e.NavigationMode == NavigationMode.Reset) RootFrame.Navigated += ClearBackStackAfterReset; } Clearing Previously Launched Pages on Fast App Resume Add Logic to App.Xaml.cs to Check for Reset Navigation(Behavior Already Implemented in Project Templates) 8/16/2014 23
  • 24. private void InitializePhoneApplication() { ... // Handle reset requests for clearing the backstack RootFrame.Navigated += CheckForResetNavigation; ... } private void CheckForResetNavigation(object sender, NavigationEventArgs e) { // If the app has received a 'reset' navigation, then we need to check // on the next navigation to see if the page stack should be reset if (e.NavigationMode == NavigationMode.Reset) RootFrame.Navigated += ClearBackStackAfterReset; } private void ClearBackStackAfterReset(object sender, NavigationEventArgs e) { // Unregister the event so it doesn't get called again RootFrame.Navigated -= ClearBackStackAfterReset; // Only clear the stack for 'new' (forward) and 'refresh' navigations if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh) return; // For UI consistency, clear the entire page stack while (RootFrame.RemoveBackEntry() != null) { } // do nothing } Clearing Previously Launched Pages on Fast App Resume Add Logic to App.Xaml.cs to Check for Reset Navigation(Behavior Already Implemented in Project Templates) 8/16/2014 24
  • 26. Maps
  • 27. Maps APIs on Windows Phone 8 • Windows Phone 8 has new Map controls, accessible in the following namespaces: • Microsoft.Phone.Maps • Microsoft.Phone.Maps.Controls • Microsoft.Phone.Maps.Services • The Bing Maps Control is still supported, but is deprecated • You should only use the Bing Maps Control when you upgrade an app from Windows Phone OS 7.1 to Windows Phone 8 • Usage of the new Maps control differs from the Bing Maps control
  • 28. ID_CAP_MAP Capability • You must include the ID_CAP_MAP capability in your app manifest • If you forget, calls to location APIs throw an UnauthorizedAccessException 8/16/2014 28
  • 29. • Add a Map to your UI •In XAML: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <maps:Map x:Name="MyMap"/> </Grid> •In Code: private void CreateMap() { Map MyMap = new Map(); ContentPanel.Children.Add(MyMap); } Map Control
  • 30. • By default, map displays at zoom level 1 (world view) and centered at Lat: 0, Long: 0 • Use the Center and ZoomLevel properties to change this, in XAML or in code //Set the Map center by using Center property MyMap.Center = new GeoCoordinate(47.6097, - 122.3331); //Set the map zoom by using ZoomLevel property MyMap.ZoomLevel = 10; Center and Zoom Level 8/16/2014 30
  • 31. • It is common to move a map display from one location to another • A new map view is defined any time the position of the map is changed as a result of panning, zooming, rotating, or tilting • You can use the SetView method to define a map view. This takes the following parameters: • Center: A GeoCoordiante object defining the center of the map view • ZoomLevel:zoom level between 1 and 20 • Heading: specifies the directional heading that is pointing “up” on the mapin geometric degrees between 0 and 360 • Pitch: specifies the degree to which the map is tilted as a value between 0 and 180 • BoundingRectangle:a LocationRectangle object that contains the Map control • AnimationKind: sets the kind of animationyou want to see (None, Linear or Parabolic) when the view changes MapViews 8/16/2014 31
  • 32. • Set the cartographic mode of the map with the CartographicMode property Cartographic Mode 8/16/2014 32 Road (default) Aerial Hybrid Terrain
  • 33. • You can display the map in a light or dark color mode by setting the ColorMode property Light and Dark Color Modes 8/16/2014 33 Light (default) Dark
  • 34. • You can display additional elements on your map, such as landmarks and pedestrian features •Set the LandmarksEnabled property to true to display landmarks •Set the PedestrianFeaturesEnabled to true to display pedestrian features • Landmarks are visible only when the ZoomLevel is 7 or higher, and the Pitch property is 25 or higher Pedestrian Features and Landmarks 8/16/2014 34
  • 36. • Unlike the Bing Maps API, the Windows Phone Maps API does not have a specific PushPin object • However, you can create your own PushPins by drawing UIElements onto a MapOverlay, then add the MapOverlay to a MapLayer which you add to the Map Pushpins 8/16/2014 36
  • 37. private Grid CreatePushpin() { //Creating a Grid element. Grid MyGrid = new Grid(); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.Background = new SolidColorBrush(Colors.Transparent); //Creating a Rectangle Rectangle MyRectangle = new Rectangle(); MyRectangle.Fill = new SolidColorBrush(Colors.Black); MyRectangle.Height = 20; MyRectangle.Width = 20; MyRectangle.SetValue(Grid.RowProperty, 0); MyRectangle.SetValue(Grid.ColumnProperty, 0); //Adding the Rectangle to the Grid MyGrid.Children.Add(MyRectangle); Creating a Pushpin 8/16/2014 37
  • 38. private Grid CreatePushpin() { //Creating a Grid element. Grid MyGrid = new Grid(); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.Background = new SolidColorBrush(Colors.Transparent); //Creating a Rectangle Rectangle MyRectangle = new Rectangle(); MyRectangle.Fill = new SolidColorBrush(Colors.Black); MyRectangle.Height = 20; MyRectangle.Width = 20; MyRectangle.SetValue(Grid.RowProperty, 0); MyRectangle.SetValue(Grid.ColumnProperty, 0); //Adding the Rectangle to the Grid MyGrid.Children.Add(MyRectangle); Creating a Pushpin 8/16/2014 38
  • 39. private void AddMapOverlay() { Grid MyGrid = CreatePushpin(); //Creating a MapOverlay and adding the Grid to it. MapOverlay MyOverlay = new MapOverlay(); MyOverlay.Content = MyGrid; MyOverlay.GeoCoordinate = new GeoCoordinate(47.6097, -122.3331); MyOverlay.PositionOrigin = new Point(0, 0.5); //Creating a MapLayer and adding the MapOverlay to it MapLayer MyLayer = new MapLayer(); MyLayer.Add(MyOverlay); MyMap.Layers.Add(MyLayer); } Drawing a UIElement onto a MapLayer 8/16/2014 39
  • 42. MapsTask MapsTaskmakes launching the built-in Maps application easy MapsTask mapsTask = new MapsTask(); //Omit the Center property to use the user's current location. mapsTask.Center = new GeoCoordinate(47.6204, -122.3493); mapsTask.SearchTerm = "coffee"; mapsTask.ZoomLevel = 17; mapsTask.Show();
  • 43. • Launchingbuilt-in Maps tasks with directions enabled is trivial too! MapsDirectionsTask 43 // Get Directions MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask(); // You can specify a label and a geocoordinate for the end point. // GeoCoordinate spaceNeedleLocation = new GeoCoordinate(47.6204,-122.3493); // LabeledMapLocation spaceNdleLML = new LabeledMapLocation("Space Needle", spaceNeedleLocation); // If you set the geocoordinate parameter to null, the label parameter // is used as a search term. LabeledMapLocation spaceNdleLML = new LabeledMapLocation("Space Needle", null); // If mapsDirectionsTask.Start is not set, the user's current location // is used as start point. mapsDirectionsTask.End = spaceNdleLML; mapsDirectionsTask.Show();
  • 44. • Use the map downloader task to enable users to download map data for offline use • The task launches the Maps settings application which allows the user to select a region of map data to download MapDownloaderTask MapDownloaderTask mapDownloaderTask = new MapDownloaderTask(); mapDownloaderTask.Show();
  • 45. • Use the map updater task to enable users to update map data they have previously downloaded for offline use • The task launches the Maps settings application which immediately checks to see if there are updates available for any previously downloaded map data MapUpdaterTask MapUpdaterTask mapUpdaterTask = new MapUpdaterTask(); mapUpdaterTask.Show();
  • 47. Summaries • Windows Phone Runtime location API is new in Windows Phone 8. It has the followingfeatures: • Accessible from managed and native code • Greater support for one-shot location acquisition • Support for Background Location Tracking • Convergent with Windows 8 • Use the new Maps APIs in Windows Phone 8 to develop maps-based apps, and incorporate location and search features • Set Center and Zoom Level • Animate to new location and zoom using map views • Select Road, Aerial, Hybrid or Terrain cartographic display modes • Draw UIElements onto a MapOverlay on top of the Map