在介面中放上三個可以更換不同語言的button,然後下面則是Bing Map,Xaml代碼如下:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page | |
x:Class="MapTest.MainPage" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="using:MapTest" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:Maps="using:Bing.Maps" | |
mc:Ignorable="d"> | |
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> | |
<Maps:Map x:Name="bingmap" Credentials="Your Key" ZoomLevel="14" Margin="0,143,0,0"/> | |
<Button Content="zh-Hant" Height="51" Margin="277,50,0,0" Width="157" Click="Button_Click"/> | |
<Button Content="ko" Height="51" Margin="498,50,0,0" Width="157" Click="Button_Click"/> | |
<Button Content="ja" Height="51" Margin="695,50,0,0" Width="157" Click="Button_Click"/> | |
</Grid> | |
</Page> |
在程式部分則必須要根據點選到的button來判斷語言,並且更換Culture屬性,這樣當點選到不同語言時,Map就會切換到對應的語系
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Bing.Maps; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Navigation; | |
namespace MapTest | |
{ | |
public sealed partial class MainPage : Page | |
{ | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
bingmap.HomeRegion = "US"; | |
} | |
protected override void OnNavigatedTo(NavigationEventArgs e) | |
{ | |
} | |
private void Button_Click(object sender, RoutedEventArgs e) | |
{ | |
switch ((sender as Button).Content.ToString()) | |
{ | |
case "zh-Hant": | |
bingmap.Culture = "zh-Hant"; | |
break; | |
case "ko": | |
bingmap.Culture = "ko"; | |
break; | |
case "ja": | |
bingmap.Culture = "ja"; | |
break; | |
} | |
} | |
} | |
} |
Culture為繁體中文
Culture為韓文
Culture為日文
而目前Bing Map所支援的Cultures可以參考下面MSDN文件
Return localized results
0 意見:
張貼留言