Use Map in Silverlight to show the location

Silverlight can support maps in a page to show a particular location. Silverlight provides the Bing map control. 

To use the bing map you need use two dll files name as Microsoft.Maps.MapControl and another one is Microsoft.Maps.MapControl.Common. Reference of this two dll is must to work with bing map.

By right clicking on the Add Reference on the project name in Solution Explorer, you can add references of these two dlls. 

Once the references are added, you can use the map control as following in your .xaml page:

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"


The first mc is for the common map dll and second for the other dll name as MapControl. 

Now, in the Grid control add the map control like below:

<m:Map x:Name="testMapUs" CredentialsProvider="XXXXXXXXXX" ScaleVisibility="Collapsed" LogoVisibility="Collapsed" CopyrightVisibility="Collapsed" Background="White" Mode="Road" Center="" ZoomLevel="12"> 
<m:Pushpin Location="00.00000,-00.00000"/> 
</m:Map>

As shown above

The CredentialProvider is the key which can provide the credential to use the map that you can get it form this website.
http://www.bing.com/mapindia/?mkt=en-in

Also from this website, you will get the actual location that you want to show in your map control.

<m:Pushpin/> tag can show the pushpin location on your map so user can get the exact location directly.

You will also get an longitude of your location from the above site. As per shown above when you use this control it show Logo, Copyright text and scale on  the map. If you do not need to display these, you can remove it by setting its Visibility property to Collapsed. 

There is different modes in the map like Road and Aerial. To change the mode of the map there is one property name as Mode="Aerial". In both mode aerial and road, you can have possible to set the zoom level as per your requirement.


X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now