Map provider initialization

4 posts, 0 answers
  1. Michal
    Michal avatar
    2 posts
    Member since:
    Sep 2010

    Posted 10 Jan 2011 Link to this post

    Hi,

    I have a problem with map initialization. Simple solution only creates a Bing provider and sets it to RadMap in window loaded event. When I run the solution, after the window is shown, it freezes for couple of seconds while it is not able to respond to user events (actually the time the window is frozen differs every time the solution is ran).

    I presume the lag is caused by map engine being initialized. The question is, why is this happening in UI dispatcher thread? Is there a way how to initialize the map without the UI freeze completely?

    Thanks for any help.

    Best Regards,
    Michal.
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 12 Jan 2011 Link to this post

    Hi Michal,

    When you assign a map provider then the map uses a UI dispatcher thread because it also initializes its internal visual elements. I would recommend assigning a map provider in the class constructor instead of the window loaded event handler.
    The example code is below.
    using System.Windows;
    using Telerik.Windows.Controls.Map;
      
    namespace WpfMapInitialization
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            private string bingApplicationId = "XXXX-YYYY-ZZZZ";
      
            public MainWindow()
            {
                InitializeComponent();
      
                var provider = new BingMapProvider(MapMode.Aerial, true, this.bingApplicationId);
                provider.IsTileCachingEnabled = true;
                this.radMap.Provider = provider;
            }
        }
    }

    Also as another way you can specify the map provider in the XAML code:
    <Window x:Class="WpfMapInitialization.MainWindow"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <telerik:RadMap
                x:Name="radMap"
                Center="40.7308244885714, -73.9974411711714"
                ZoomLevel="16">
                <telerik:RadMap.Provider>
                    <telerik:BingMapProvider Mode="Aerial" IsLabelVisible="True" IsTileCachingEnabled="True" ApplicationId="XXXX-YYYY-ZZZZ" />
                </telerik:RadMap.Provider>
            </telerik:RadMap>
        </Grid>
    </Window>

    Regards,
    Andrey Murzov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michal
    Michal avatar
    2 posts
    Member since:
    Sep 2010

    Posted 14 Jan 2011 Link to this post

    Hi Andrey.

    Thank you for the answer but unfortunately it did not solve my problem at all. Actually I have had the provider initialization in the constructor before but the problem was the window showed only after map initialization finished. Nevertheless the time the application is irresponsible due to the map initializing in UI dispatcher thread is not any shorter.

    That brings me back to my previous question. Is there a way how to initialize the map without the application become irresponsible?

    I believe it is not very good application design to allow the application to stop responding to user events for couple of seconds (strange thing is the time vary from 3 seconds to 20 seconds - tested on 3 different computers). Actually the demo application that ships with your components behaves very same way - application freezes for a period of time.

    Thanks for any suggestions.

    Best regards,
    Michal.
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 19 Jan 2011 Link to this post

    Hi Michal,

    We have tried to reproduce the problem with freezing application for a couple of seconds during initialization, but unsuccessfully. It is very complicated and it is hard to reproduce the problem without your code and/or your local environment.
    Could you, please, provide us with a small sample solution for reproducing the problem?
    Also could you try to create a sample solution which uses the open street map provider to check a time of initialization on your local environment?
    If the initialization using the open street map provider is quick, then the frizzing can be a result of initializing of the Bing Maps imagery service. We use asynchronous request for it, but the code of WCF service client is generated by Visual Studio. So, we can't be sure completely that for example unstable internet connection cannot be a cause of this problem.

    Greetings,
    Andrey Murzov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top