As described in the first article of this series, developing Bing Maps based on Silverlight requires a development Key in addition to the development environment. What is this Key used? The Silverlight control is an essential parameter for map rendering. It can be understood as Microsoft Bing Maps, which is an authorization Development Key activated by users, this article attempts to use a simple example drill project to learn how the Bing Maps control uses this Key to display Maps.
1. Create a Silverlight application and a Silverlight bearer Application
Starting from the simplest project creation, we first create a blank solution, then add a new Silverlight application to the solution, and create a bearer program for the Silverlight application (usually ASP. NET Web Application or ASP. NET WebSite), as follows:
Ii. How to Use Bing Maps Silverlight Control to display a map
Open the local installation directory of Bing Maps Silverlight Control, which contains two. dll files: Microsoft. maps. mapControl. common. dll and Microsoft. maps. mapControl. dll to introduce these two library files to the Silverlight project created above, and then open MainPage. the source attempt of the xaml is to introduce Bing Maps Silverlight Control to the current Silverlight page through the namespace. The following code example:
1 <UserControl x: Class = "BingMaps. MainPage"
2 xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns: m = "clr-namespace: Microsoft. Maps. MapControl; assembly = Microsoft. Maps. MapControl"
5 xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
6 xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
7 mc: Ignorable = "d" d: DesignWidth = "640" d: DesignHeight = "480">
8 <Grid x: Name = "LayoutRoot">
9
10 </Grid>
11 </UserControl>
For example, if we present a map in a Grid, we can encode the map as follows:
1 <UserControl x: Class = "BingMaps. MainPage"
2 xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns: m = "clr-namespace: Microsoft. Maps. MapControl; assembly = Microsoft. Maps. MapControl"
5 xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
6 xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
7 mc: Ignorable = "d" d: DesignWidth = "640" d: DesignHeight = "480">
8 <Grid x: Name = "LayoutRoot">
9 <m: Map CredentialsProvider = "allow"
10 Width = "500"
11 Height = "500" type = "codeph" text = "codeph">
12 </m: Map>
13 </Grid>
14 </UserControl>
15
In the Map control (Map), CredentialsProvider is the Key we used to create through the Bing Maps Account Management Center. The Width and Height attribute values are used to determine the Width and Height of the Map control. Compile and start the program to preview and find that the default map (the development of other Maps will be described in the blog later) has been successfully presented through Bing Maps Silverlight Control, for example:
Iii. Other functional attributes
As shown in, there is a navigation toolbar for the Map in the upper-left corner of the Map. You can use the NavigationVisibility attribute of the Map control to set whether to display the function navigation.
1 <m: Map CredentialsProvider = "deny"
2 NavigationVisibility = "Collapsed" Width = "500" Height = "500">
3 </m: Map>
You can also set the map display mode, which can be Road or satellite. The control is loaded into Road condition by default, the following code uses the Road mode:
1 <m: Map CredentialsProvider = "role" Name = "map"
2 Width = "500" Height = "500" Mode = "Road">
3 </m: Map>
If the Mode is set to "Aerial", the map is loaded in satellite Mode, and Aerial is in non-lustful satellite Mode. to display the road signs, you need to use "AerialWithLabels" to load the map. The following code:
1 <m: Map CredentialsProvider = "role" Name = "map"
2 Width = "500" Height = "500" Mode = "AerialWithLabels">
3 </m: Map>
We can also set a slow effect for the road sign. When the mouse points to the road sign, the road sign is displayed slowly and hidden slowly after leaving.
<M: Map CredentialsProvider = "role" Name = "map"
Center = "37.806029,-122.407007">
<M: Map. Mode>
<M: AerialMode Labels = "True" FadingLabels = "True"/>
</M: Map. Mode>
</M: Map>
Description
This document is a learning note and is intended to be shared with people with lofty ideals. You are welcome to repost this article, but mark the original article connection in a prominent position.
Author: Beniao
Article Source: http://beniao.cnblogs.com/or http://www.cnblogs.com/