案例:Windows Phone 7(芒果)應用程序。是否可以將視圖從Bing地圖渲染到WriteableBitmap?
我有(數百個)項目列表,其中包含地理座標。每個項目的參數數據都用於渲染圖像,並且這些圖像顯示在列表框中。
是否可以將WP7地圖元素渲染到可寫位圖?如果沒有,是否可以從地圖元素禁用UI手勢,所以它至少表現得像一個靜態圖像?
案例:Windows Phone 7(芒果)應用程序。是否可以將視圖從Bing地圖渲染到WriteableBitmap?
我有(數百個)項目列表,其中包含地理座標。每個項目的參數數據都用於渲染圖像,並且這些圖像顯示在列表框中。
是否可以將WP7地圖元素渲染到可寫位圖?如果沒有,是否可以從地圖元素禁用UI手勢,所以它至少表現得像一個靜態圖像?
如果你只是想要一個地圖的靜態圖像,我會建議使用Static Map API for Bing爲每個列表項目映射而不是Map控件。
靜態地圖API還允許您指定圖像大小,以便減少手機的下載大小。
如果你仍然想使用Bing地圖控件,您可以通過在XAML IsHitTestVisible設置爲false,這樣禁用UI手勢:
<my:Map IsHitTestVisible="False" />
從GFTab
嘗試在評論所說的例子爲使其靜態的,你可以嘗試IsHitTestVisible =「假」
這裏是我從areay做了次平鋪currenly在應用程序中可見:
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
}
}
截圖? http://www.developer.nokia.com/Community/Wiki/How_to_capture_screen_programmatically_in_Windows_Phone_7 – GETah