In this week's Inside Windows Phone we talk about Location and Mapping in Windows Phone 8. In this video we cover The basics of location and mapping The power of Windows Phone location and mapping APIs including simple ways to do distance calculations, reverse geocoding (get an address from a latitude/longitude), mapping routes (both walking and driving) and how to point users to download offline maps to drive a powerful mapping experience available worldwide even in the absence of network connectivity. All code from this video is available here. Getting started with location in Windows Phone takes about 5 minutes. Windows Phone Location and Mapping in 5 Minutes Minute 1: Enable your app for mapping and location tracking. Open up a new Windows Phone 8 project. Double-click on the WMAppManifest.xml file Go to the Capabilities tab and check the ID_CAP_LOCATION and ID_CAP_MAP capabilities. This gives you application permission to use the location APIs and the Map control. Minute 2: Add a map control. Open up your MainPage.xaml in either Visual Studio or Blend. Go to the Toolbox in Visual Studio or the Assets pane in Blend and type "Map" in the search box. Double click or click-and-drag to add it to your XAML control. In Visual Studio 2012: In Blend for VS 2012 Minute 3: Get your location Open up MainPage.xaml.cs (also known as your code-behind). Add a Geolocator variable and initialize it in your constructor. You will need to add Windows.Devices.Geolocation as a reference. Geolocator locator;
public MainPage()
{
InitializeComponent();
locator = new Geolocator();
this.Loaded += MainPage_Loaded;
} Change your MainPage_Loaded to enable await operations by adding "async" before "void" and add the following code: async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
try
{
Geoposition myLocation = await locator.GetGeopositionAsync();
GeoCoordinate geoCord = new GeoCoordinate(