2012-06-28 52 views
1

案例:Windows Phone 7(芒果)应用程序。是否可以将视图从Bing地图渲染到WriteableBitmap?

我有(数百个)项目列表,其中包含地理坐标。每个项目的参数数据都用于渲染图像,并且这些图像显示在列表框中。

是否可以将WP7地图元素渲染到可写位图?如果没有,是否可以从地图元素禁用UI手势,所以它至少表现得像一个静态图像?

+0

截图? http://www.developer.nokia.com/Community/Wiki/How_to_capture_screen_programmatically_in_Windows_Phone_7 – GETah

回答

1

如果你只是想要一个地图的静态图像,我会建议使用Static Map API for Bing为每个列表项目映射而不是Map控件。

静态地图API还允许您指定图像大小,以便减少手机的下载大小。

如果你仍然想使用Bing地图控件,您可以通过在XAML IsHitTestVisible设置为false,这样禁用UI手势:

<my:Map IsHitTestVisible="False" /> 
0

GFTab

尝试在评论所说的例子为使其静态的,你可以尝试IsHitTestVisible =“假”

0

这里是我从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 
     } 
    }