您的位置:首页 > 其它

[Windwos Phone] 实作地图缩放 MapAnimationKind 属性效果

2014-03-08 21:16 489 查看
原文:[Windwos Phone] 实作地图缩放 MapAnimationKind 属性效果


[前言]

使用经纬度来定位地图的位置,以及使用 MapAnimationKind 属性来设定地图缩放时的动画。

?


[成品]



??

??

??



?


[范例]

Step1. 新增 Windows Phone 应用程式专案。





?

Step2. 指定应用程式使用 ID_CAP_MAP 功能

方案总管 -->Properties 资料夹--> WMAppManifest.xml --> 功能 --> 勾选ID_CAP_MAP。







?

Step3. 加入地图的命名空间。





xmlns:maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"


?

Step4. 画面设计

maps:Map-->Name="map",Heading="0",Center="25.0405,121.5146",ZoomLevel="10",Margin="0,61,0,10"

Button-->Name="btCenter",Content="置中",Margin="0,-11,339,546"

Button-->Name="btAnom",Content="缩放动画",Margin="106,-11,202,546

?

XAML 程式码:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<maps:Map x:Name="map" Heading="0" Center="25.0405,121.5146" ZoomLevel="10" Margin="0,61,0,10"/>
<Button Name="btCenter" Content="置中" Margin="0,-11,339,546"/>
<Button Name="btAnom" Content="缩放动画" Margin="106,-11,202,546"/>
</Grid>


?

Step5. 产生btCenter / btAnom 按钮的 Click 事件。

// 建构函式
public MainPage()
{
InitializeComponent();
//产生btCenter / btAnom Click事件,+=後按下 Tab 2下产生事件
btCenter.Click += btCenter_Click;
btAnom .Click+= btAnom_Click;
}


?

Step6. btCenter / btAnom 的 Click 事件内容。

private void btCenter_Click(object sender, RoutedEventArgs e)
{
//把位置(25.0405, 121.5146)的位置设置在中间
map.Center = new GeoCoordinate(25.0405, 121.5146);
//地图的比例为12
map.ZoomLevel = 12;
}

private void btAnom_Click(object sender, RoutedEventArgs e)
{
//设置地图在缩放时显示动画的效果
map.SetView(new GeoCoordinate(25.0405, 121.5146), 16, MapAnimationKind.Parabolic);
}


?


[相关参考与引用]

Map.SetView Method (GeoCoordinate, Double, Double, MapAnimationKind)

?


[范例下载]

Map 缩放.rar

var now = new Date();var index=now.getTime();document.write('');



posted on 2013/11/24 01:28 |
阅读数 : 965
|

2 人推荐

我要推荐

|
Add Comment

| 文章分类 [

Windows Phone

]

|
订阅
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: