Microsoft Surface--Bing™ Maps WPF Control

     最近Bing maps团队为我们带来了Bing™ Maps WPF Control ,现在是Beta 1版本,现在我们可以为Microsoft Surface提供地图开发。

新建项目

添加引用

Xaml Code:

1  xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF" 

  

BingMaps使用

使用BingMaps前需要注册获得 Bing Maps Key

Xaml Code:

1 <Grid>
2 <m:Map ZoomLevel="2"
3 x:Name="Map" CredentialsProvider="your key goes here">
4 <m:Map.Mode>
5 <m:AerialMode Labels="True" />
6 </m:Map.Mode>
7 <m:Pushpin Location="33.845881352,105.165628188471"></m:Pushpin>
8 </m:Map>
9 </Grid>

  演示:

添加定位功能:

Xaml Code:

 1 <Grid>
2 <m:Map ZoomLevel="2"
3 x:Name="Map" CredentialsProvider="your key goes here">
4 <m:Map.Mode>
5 <m:AerialMode Labels="True" />
6 </m:Map.Mode>
7 <m:Pushpin Location="33.845881352,105.165628188471"></m:Pushpin>
8 </m:Map>
9
10 <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Width="170" Height="120" Opacity="0.66" Background="Bisque">
11 <TextBlock HorizontalAlignment="Left" Foreground="Red">度:</TextBlock>
12 <TextBox x:Name="tbLongitude" Text="0.0" TextAlignment="Right"></TextBox>
13 <TextBlock HorizontalAlignment="Left" Foreground="Red">纬度:</TextBlock>
14 <TextBox x:Name="tbLatitude" Text="0.0" TextAlignment="Right"></TextBox>
15 <Button Width="80" Height="30" Click="Button_Click">
16 <TextBlock>定位</TextBlock>
17 </Button>
18 </StackPanel>
19 </Grid>

  C# Code:

 private void Button_Click(object sender, RoutedEventArgs e)
        {
            double latitude = 0;
            double longitude = 0;
            double.TryParse(tbLatitude.Text, out latitude);
            double.TryParse(tbLongitude.Text, out longitude);
            this.Map.SetView(new Location(latitude, longitude), 5);
        }

  最后演示:

好了,就到这里了。

转载时须注明本文的详细链接,否则作者将保留追究其法律责任

出处:http://www.cnblogs.com/flute-di/

作者:王迪

转载于:https://www.cnblogs.com/flute-di/archive/2011/09/07/2169774.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值