Print Map control

4 posts, 0 answers
  1. Iwan van Ee
    Iwan van Ee avatar
    21 posts
    Member since:
    Dec 2009

    Posted 29 Nov 2012 Link to this post

    Can I print the Map from the Mapcontrol? And even more specific can we print on papersizes bigger than A3?
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 03 Dec 2012 Link to this post

    Hi Iwan,

    The printing of the RadMap content could be done using standard Silverlight approach.
    The sample code is below.
    <UserControl x:Class="Printing.MainPage"
        mc:Ignorable="d"
        Height="300" Width="400"
        d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadMap x:Name="radMap"
                            ZoomLevel="4"
                            Center="37.684297,-99.06924">
            </telerik:RadMap>
            <Button Content="Print"
                    Name="btnPrint"
                    Width="75"
                    Height="23"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Top"
                    Click="btnPrint_Click" />
        </Grid>
    </UserControl>

    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Printing;
    using Telerik.Windows.Controls.Map;
       
    namespace Printing
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
       
                var provider = new OpenStreetMapProvider();
                radMap.Provider = provider;
            }
       
            private void btnPrint_Click(object sender, RoutedEventArgs e)
            {
                PrintDocument document = new PrintDocument();
                document.PrintPage += (s, args) =>
                {
                    args.PageVisual = this.radMap;
                };
               
                document.Print("Silverlight Print Application Demo");
            }
        }
    }

    Kind regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Adam
    Adam avatar
    2 posts
    Member since:
    May 2013

    Posted 21 May 2013 Link to this post

    i like this idea but i wonder what i should do if i want add lanscape A1 ,  lanscape A2 ,lanscape A3 in combobox ??

  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 22 May 2013 Link to this post

    Hello Adam,

    Actually this topic is a bit outside of the scope of the RadMap support. But I did a few experiments and searched on the Internet for a possible solution. I've found a very good article on Silverlight printing (including landscape printing) with ready to use code:

    http://www.codeproject.com/KB/silverlight/SilverlightEasyPrint.aspx

    I've copied the code from this page to my sample application and I was able to print RadMap in landscape mode with full map fit to page. The calling code is simple (it is possible after adding the code from this article):
    <ScrollViewer Width="600" Height="400" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
        <telerik:RadMap x:Name="radMap" Width="1000" Height="800">
            <telerik:RadMap.Provider>
                <telerik:OpenStreetMapProvider />
            </telerik:RadMap.Provider>
        </telerik:RadMap>
    </ScrollViewer>
    this.radMap.Print("Map",
        HorizontalAlignment.Stretch,
        VerticalAlignment.Stretch,
        new Thickness(10),
        true,
        true,
        null);

    I hope it will help you.

    All the best,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top