Using Bing Maps in Universal Windows App

Now a days, integration of maps within an application is common and developers wants to integrate their application to use maps. So, in this post, we will create an Universal Windows Application to use Bing Maps Api and utilize Maps functionality within the application.

For creating this application, first, we will create an Universal Windows App in Visual studio. Then, we will open our XAML file of the page and add the following code for the map:

After adding the code in designer, we will add following namespaces in the .CS file of the page to use code for fetching current location of a person and showing it on the map:

Now, we will add the code for our Button Click event handler for “Get Location” Button and Selection Changed event handler for Combo box for our view:

Now, we have written the code to fetch the current location of a person and show it in the map. Add pin.png to the Assets folder of the solution to show the pin on the current location on the map.

After we are done with our application in Visual Studio, we will be creating an app on Bings Map Portal which will give us the Api Key to use for fetching map from Bing Maps site.

Now, the steps to create a key for on Bing Maps Portal are:

Go to -> Sign In (with outlook account) -> My Accounts -> Create or View keys -> Click here to Create new Key -> Enter Application Name which you created in Visual Studio (Use exact name as in Visual Studio) -> Select Application Type -> Create

After the above steps, you can find the list of application below on the same page and there click on Copy Key to copy the key. It looks like below:maps1


Now, copy the key and paste it in MapServiceToken property of the MapControl control on the XAML file of the page.

Run the application and enjoy!