Howto create image from RadMap without showing the RadMap

2 posts, 0 answers
  1. Janko
    Janko avatar
    7 posts
    Member since:
    Sep 2012

    Posted 13 Sep Link to this post

    I use a very general image creation method to create multiple images for a report.
    This method doesn't yet work with RadMap because there are unfinished animations (Zooming, ...(?)) and the OpenStreetMap data isn't loaded and shown yet

    Questions:
    1) Can I disable the RadMap animations and get an eventcall when the map loading and creation process is finished?
       Or is there even a better way to implement it?
    2) Is it possible to use something like a cache for the openStreetMap data during my report creation
    3) Is it possible to use the OpenStreetMapProvider offline?


    image creation method:
    var outerGrid = CreateNewViewAndSetDataContextCreateViewInGrid(myDataContext);
    outerGrid.Width = width;
    outerGrid.Height = height;
    outerGrid.Measure(new Size(width, height));
    outerGrid.Arrange(new Rect(0, 0, width, height));
    outerGrid.UpdateLayout();
    var renderTargetBitmap = new RenderTargetBitmap(
       (int)width,
       (int)height,
       96,
       96,
       System.Windows.Media.PixelFormats.Pbgra32);
    renderTargetBitmap.Render(outerGrid);
    var bitmapEncoder = new PngBitmapEncoder();
    bitmapEncoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
    return bitmapEncoder;



    RadMap Code:
    <telerik:RadMap x:Name="Map" MiniMapExpanderVisibility="Collapsed">
        <telerik:RadMap.Provider>
            <telerik:OpenStreetMapProvider x:Name="MapProvider"/>
        </telerik:RadMap.Provider>
        <telerik:VisualizationLayer x:Name="LayerInMap"/>
    </telerik:RadMap>


    RadMap Code Behind:
    this.DataContextChanged += /* set map properties. e.g. fill visualization layer with charts */

  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    496 posts

    Posted 18 Sep Link to this post

    Hello Janko,

    Thank you for the provided code snippets. 

    I will go straight to your questions:

    1) Can I disable the RadMap animations and get an eventcall when the map loading and creation process is finished?
       Or is there even a better way to implement it?

    You can try the Loaded event of the RadMap and you can also use a Dispatcher with a lower DispatcherPriority in order to make sure that everything is loaded. 

    2) Is it possible to use something like a cache for the openStreetMap data during my report creation

    3) Is it possible to use the OpenStreetMapProvider offline?

    To address both 2) and 3) together, you can check out the following threads for more information on the topic of caching and offline usage: 

    Offline Map Server

    Offline TiledMapProvider

    I hope you find this helpful.

    Regards,
    Vladimir Stoyanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top