案例:Windows Phone 7(芒果)应用程序。
我有一个包含地理坐标的(数百个)项目列表。每个项目的参数数据用于渲染图像,这些图像显示在列表框中。
是否可以将WP7 Map元素渲染为writeablebitmap?如果没有,是否可以从地图元素中禁用UI手势,因此它至少表现得像静态图像?
答案 0 :(得分:1)
如果您只想要一张地图的静态图片,我建议您为每个列表项使用Static Map API for Bing地图而不是地图控件。
静态地图API还允许您指定图像大小,以便减少手机的下载大小。
如果您仍想使用Bing Map控件,可以通过将IsHitTestVisible设置为false来禁用UI手势,如XAML中所示:
<my:Map IsHitTestVisible="False" />
答案 1 :(得分:0)
尝试 GFTab
的评论中建议的示例为了使其静止,您可以尝试IsHitTestVisible =“False”
答案 2 :(得分:0)
以下是我如何从应用程序中当前可见的数组中创建辅助磁贴:
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
}
}