[英]Is it possible to render a view from Bing Maps to a WriteableBitmap?
案例:Windows Phone 7(Mango)應用程序。
我有一個(數百個)項目列表,其中包含一個地理坐標。 每個項目的參數數據都用於渲染圖像,並且這些圖像顯示在列表框中。
是否可以將WP7 Map元素呈現為writeablebitmap? 如果不是,是否可以從map元素禁用UI手勢,因此它至少表現得像靜態圖像一樣?
嘗試GFTab評論中建議的示例
為了使其靜態,可以嘗試IsHitTestVisible =“ False”
這是我如何從當前在應用程序中可見的區域中創建輔助磁貼:
private void pinCurrentMapCenterAsSecondaryTile() {
try {
var usCultureInfo = new CultureInfo("en-US");
var latitude = map.Center.Latitude.ToString(usCultureInfo.NumberFormat);
var longitude = map.Center.Longitude.ToString(usCultureInfo.NumberFormat);
var zoom = map.ZoomLevel.ToString(usCultureInfo.NumberFormat);
var tileParam = "Lat=" + latitude + "&Lon=" + longitude + "&Zoom=" + zoom;
if (null != App.CheckIfTileExist(tileParam)) return; // tile for exactly this view already exists
using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
var fileName = "/Shared/ShellContent/" + tileParam + ".jpg";
if (store.FileExists(fileName)) {
store.DeleteFile(fileName);
}
// hide pushpins and stuff
foreach (var layer in map.Children.OfType<MapLayer>()) {
layer.Visibility = Visibility.Collapsed;
}
using (var saveFileStream = new IsolatedStorageFileStream(fileName, FileMode.Create, store)) {
var wb = new WriteableBitmap(173, 173);
b.Render(
map,// the map defined in XAML
new TranslateTransform {
// use the transformation to clip the center of the current map-view
X = -(map.ActualWidth - 173)/2,
Y = -(map.ActualHeight - 173)/2,
});
wb.Invalidate();
wb.SaveJpeg(saveFileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
}
foreach (var layer in map.Children.OfType<MapLayer>()) {
layer.Visibility = Visibility.Visible;
}
}
ShellTile.Create(
new Uri("/MainPage.xaml?" + tileParam, UriKind.Relative),
new StandardTileData {
BackTitle = "ApplicationName",
Count = 0,
// You can only load images from the web or isolated storage onto secondary tiles
BackgroundImage = new Uri("isostore:/Shared/ShellContent/" + tileParam + ".jpg", UriKind.Absolute),
});
} catch (Exception e) {
// yeah, this is 7331!!11elfelf
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.