Monday, January 2, 2012

Bing Maps Control For Windows Phone 7

0 comments

Bing Maps Silverlight Control for Windows Phone combines the powers of Silverlight and Bing Maps to support applications. Developers can now use Bing Maps Silverlight Control, which includes location and search services. For those of you who are quite familiar with using this control in standard Silverlight applications, you surely won’t see any difficulties to use the control in your Windows Phone applications.
To be able to use this service, you have to register in order to get a key to use control, SOAP Services, REST, and Bing Spatial Data Services. Without a valid key we will not be able to fetch data via web.

Registering Bing Maps Account

1 – Open your browser and go to page http://www.bingmapsportal.com
2 – Select Create to make a new account using Windows Live ID.
3 – Complete your registration data on the next page.
4 – After it’s finished, create a new key for your application. Select Create or view keys from the links on the left.
Bing Maps Control For Windows Phone 7
5 – Complete the application details, and click Create key. Secure this key for later purposes.
Bing Maps Control For Windows Phone 7

Using Bing Maps Control

1 – If you continue from the previously made project, then add a page to learn about Bing Maps. Otherwise, create a new project for this purpose. Having been doing exercises up to this page, it should be fairly easy to do. The following example uses a previously existing project. Right click on the project, Add New Item, selectWindows Phone Portrait Page and rename the file, in this example BingMaps.xaml then select Add.
Bing Maps Control For Windows Phone 7
2 – Add a Map Control from the toolbox
Bing Maps Control For Windows Phone 7
3 – Change the properties in WMAppManifest.xml so that BingMaps.xaml is the initial page for the application. Press F5 and see the results
Bing Maps Control For Windows Phone 7
On the center of the control you will see a warning: “Invalid Credentials. Sign up for a developer account”. This indicates that you haven’t inserted your key, which will allow you to use Bing maps services.
4 – Open BingMaps.xaml file and insert your key.
Bing Maps Control For Windows Phone 7
5 – Press F5 and see that the warning has disappeared.
Bing Maps Control For Windows Phone 7
6 – Now we add a simple functionality that will automatically add a marker, or more generally known asPushpin, whenever we click on an area on the map. Add an event handler to handle click event on the map.
Bing Maps Control For Windows Phone 7
7 – Press F5 and see the result. Click anywhere to add a marker on the map.
Bing Maps Control For Windows Phone 7
Pretty simple, isn’t it? The addition of map control on Windows Phone gives developers more freedom to enrich user experiences, especially on using maps and other Bing Maps services. The topic about Bing Maps Control Silverlight itself has a very wide scope which will not be discussed further here. If you are interested, you can see references on MSDN site or Interactive SDK for Silverlight.

Leave a Reply