Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Dinesh's Blog
Browse by Tags · View All
brh 20
#SILVERLIGHT 19
#DOTNET 18
silverlight 18
#ASP.NET 15
Silverlight 4.0 9
bing 7
bing maps 6
wcf services 5
map 5

Archive · View All
August 2010 10
September 2010 3
July 2010 3
June 2010 3
October 2010 1

Getting Started with Bing Map in Silverlight

Jun 22 2010 3:50PM by Dinesh Sodani   

For the majority of us, maps represent a useful tool which we often use in daily life when we are looking for a specific landmark, shopping centre or street name in an unfamiliar town or city.

For business, map is a good marketing tool to attract the customers. Many Companies use Google Map to show its location so that customers can easily reach them.

In this walkthrough I will show how to create a Silverlight application with Bing Map Control. Bing Map control is provided by Microsoft Virtual Earth. Bing Map can be integrated in website by two ways:

    • Bing Map AJAX control
    • Bing Map Silverlight control

Silverlight have rich set of controls which provide better user experience.

To start you need to download and install following development tools:

image1

Microsoft Visual Studio 2008 SP1

image2

Microsoft Silverlight 3 Tools for Visual Studio 2008 SP1

image3

Bing Maps Silverlight Control SDK v 1.0.1

Create New Bing Maps Silverlight Application with Visual Studio:

Start Visual Studio 2008 and choose File > New > Project

Select Silverlight from the Project types tree, and Silverlight Application from the Templates list.

Give your application a name and click OK.

New Project

A dialog will appear asking if you want to host the application in a new web site. Make sure this option is checked, select ASP.NET Web Application Project, and click OK.

New Project With Web

Once project is created simply run the project. You should see a blank web page with URL starting as http://localhost. This confirms that the project is being served by the ASP .NET development server.

Now you need to add reference of Bing Map control’s dll.

Right click on the References folder in the Demo1 project and choose Add Reference.

Add Reference

Select the Browse tab and browse to the Libraries directory in the Bing Maps Silverlight Control installation folder. The default installation location is C:\Program Files\Bing Maps Silverlight Control\V1\Libraries.

Select both the Microsoft.Maps.MapControl.dll and Microsoft.Maps.MapControl.Common.dll assemblies, and click OK.

Add Reference dll

Modify the xaml for the MainPage.xaml user control by adding following xml namespace declaration for the Bing Maps assembly.

xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl" 
<UserControl x:Class="Demo1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
      
    </Grid>
</UserControl>

Now add following tag which will creates the Map object:

<m:Map x:Name="MyMap"/>

Press F5 and see you have the map in your browser. But you will discover that a map appears in the browser with a message to say that you have invalid credentials.

First Map

You need to obtain a Windows Live Id and create an account here https://www.bingmapsportal.com/Account/Register

To obtain the key, enter the Application Name and the URL, and click the Create Key button.

Key

Once you have a key you can apply it by assigning it to the CredentialsProvider property:

<m:Map  x:Name="MyMap" CredentialsProvider="YOUR KEY"/>

Now you can see the map without that message.

The map that appears now is showing the whole world. If you want to show one specific region let say New York as default and zoom up to certain level add code in MainPage.xaml.cs file

using Microsoft.Maps.MapControl;

In MainPage() function after InitializeComponent() add following;

MyMap.Center = new Location(40.71990, -73.99);
MyMap.ZoomLevel = 11;

Here 40.71990, -73.99 is Longitude and Latitude of New York, USA.

Following will add a Icon on the map to show particular location.

<m:Map  x:Name="MyMap" CredentialsProvider="YOUR KEY"
       Mode="Road"  RenderTransformOrigin="0.42,0.557" Margin="0,0,0,0"
       LogoVisibility="Collapsed"  >
       <m:Pushpin Location="40.71990, -73.99">
       </m:Pushpin>
</m:Map>
NY Map with Push Pin

Hope you enjoy the post !!!

Recently I came across a requirement to show all the customers on the Map.That will help marketing personals and top management to analyze the regional sales.

In the next article I will show how to Show Multiple Locations on the map by fetching customer data from database!!!

Tags: bing maps, map, silverlight, bing, brh, #DOTNET, #SILVERLIGHT,


Dinesh Sodani
30 · 6% · 1807
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

1  Comments  

  • Hey Dinesh,

    Is it possible to implement Bing maps with SharpMap ? Because I want it to be able to read shape files which can be queried from the database. does Bing Support shape files ?? if Not, what data does it use ?

    commented on Jul 14 2011 9:32AM
    mahesh.hika
    2895 · 0% · 2

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]