Windows Phone 載入BingMaps中文版地圖

來源:互聯網
上載者:User

相信有很多人在開發WP7的時候都用過BM控制項

但是作為一個中國人,看著純英文版的地圖,還是覺得有點彆扭

所以特意在網上搜了一下方法,然後自己實現出來,現在分享給大家!

首先在XAML代碼裡添加如下代碼

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

  

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            <my:Map x:Name="myMap" HorizontalAlignment="Left" VerticalAlignment="Top"                    Height="607" Width="456" Margin="0"                    CredentialsProvider="[LIVEID]"                     LogoVisibility="Collapsed"                    CopyrightVisibility="Collapsed"                    ZoomBarVisibility="Visible"/>
</Grid>

接下來在xaml.cs檔案裡添加如下代碼:

void MainPage_Loaded(object sender, RoutedEventArgs e)        {            UriBuilder tileSourceUri = new UriBuilder("http://r2.tiles.ditu.live.com/tiles/r{quadkey}.png?g=41");            MapTileLayer tileLayer = new MapTileLayer();            Microsoft.Phone.Controls.Maps.Platform.Location first = new Microsoft.Phone.Controls.Maps.Platform.Location();            first.Latitude = 60;            first.Longitude = 60;            LocationRectTileSource tileSource = new LocationRectTileSource(tileSourceUri.Uri.ToString(),                 new LocationRect(first, 180, 180), new Range<double>(1, 16));            tileLayer.TileSources.Add(tileSource);            tileLayer.Opacity = 0.9;            myMap.Children.Add(tileLayer);            myMap.Mode = new MercatorMode();        }

下面試運行後的效果:

源碼如下:

http://dl.dbank.com/c01t5zidso

 

另外小弟建了個WP7開發交流QQ群,歡迎部落格的各位大牛、小牛們哈

QQ群號:170716593

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.