Enabling Location Capability with Bing Map in Windows Store App (XAML)


In this article we would see how to enable Location in your Windows Store App (XAML) and integration with Bing Map.

Creating Windows Store App (XAML)

To create a Windows Store App (XAML), fire Visual Studio 2012 and choose your required template under Visual C#. In this example I am creating a blank app.

Adding Bing Map Control to your XAML

Not necessarily Location Capability requires a Bing Map control to be added to your design. This demo is to integrate the Location capability with the Bing Map.

To Add Bing Map to your XAML app, follow my previous article “Starting Bing Map for Windows Store App (XAML)“.

Adding Location Capability

To Add Location to the Windows Store, you need to add the Capability in your project’s manifest. To open the manifest in GUI mode; double click on the “Package.appxmanifest” file which is located under root folder of the project.

Navigate to the Capabilities tab and select Location.

As soon as your app is Location enabled. When you launch the app, it would ask you to use the location. Follow below image.

Adding a Pushpin to the Geolocator Position

Here is what we would do, we would add a push pin to the current location. To do this you need to add a push pin to the map.

We would call a method which would help us to find the current location using Geolocator instance.

And finally, this async method would give us the current position, which is again dependent on your internet/data connection.

As we have already set the zoom level to be 15.0f, the location would be looking like animating.

Hope this article helps, thanks for reading.

Download Source code: Click Here