Microsoft’s Bing search engine (which the company calls a “decision engine”) allows you to search the Internet, but also work with maps interactively. As you could expect from the developer-friendly company, creating applications that use the Bing Maps functionality has been made easy. For instance, you can add a Bing Maps control into your Silverlight applications, and run them on the web, the desktop and on Windows Phone 7.
In addition to basic map display functionality (see Figure 1), you can also programmatically manipulate the map. For instance, you can add pushpins to mark your location, add areas, or even integrate media onto the map. For instance, a video could start playing at a particular location when you zoom in enough on the map. Furthermore, you can switch your view to an aerial view, or at certain urban locations, the bird’s view.
Figure 1. A Bing map on the web browser.
In many situations, Bing Maps is a free service for both profit and non-profit organizations. However, the application (solution) you are developing must be a publicly facing web application, and the map functionality must not be password protected. Furthermore, there is a limit to 125.000 sessions per year. If your needs are above that or you want to integrate Bing Maps with your internal applications, you must discuss licensing with Microsoft. For mobile applications, Bing Maps is free if it is provided in a publicly distributed application and does not display real-time traffic data.
In this article, you are going to learn how you can get started with Bing Maps in your own applications. Two example solutions are given: a traditional Silverlight 4.0 application for web use and another that works with a Windows Phone 7 device. Sample code is shown for C# programming, and Microsoft Visual Studio 2010 with the Windows Phone 7 Tools used as the development tool.
Registering for a Bing Maps Developer Account
Bing Maps is a free service for public-facing web applications and Windows Phone 7 applications available through the Windows Marketplace. Although you can freely browse the maps on the Bing Maps web site at http://maps.bing.com/, using the same maps in your own applications or web sites requires you to register as a developer.
This registration process is a straightforward process and similar to many other web based registrations. You simply point your browser to the Bing Maps Account Center at www.bingmapsportal.com and then log in with a Microsoft Live ID (see Figure 2). Once you have logged in and registered, you can access your developer key from the top-left corner of the web portal. From there, you can find a section named “Map APIs”, under which you can find a link to “Create or view keys”.
Figure 2. To be able to use a map in your own applications, you need to register for a developer key.
If you click this link, you will see an orange-ish box to create a new developer key. You must give your application a name (it could be “Test”) and an URL pointing to your application. In a production application, this should be a public URL, but for testing and development work, you can just type in “
http://localhost/“. For the application type, select for instance “Developer” or “Evaluation/Trial”. After pressing the submit button, you will receive your developer key, which is a long string of alphanumeric characters.
The same map portal that allowed you to create your developer key also lets you access the Bing Maps Silverlight Control download page. To be able to use Bing maps in your Silverlight applications, you will need to download this control. The control has been designed for Microsoft Visual Studio 2010 and the separate Silverlight 4 Tools for Microsoft Visual Studio. Remember also that you will need to have the latest Silverlight developer runtime as well. If you forget to install the runtime, Microsoft Visual Studio will kindly prompt you to download it.