This is a migrated thread and some comments may be shown as answers.

BingMapProvider and Unpinned RadPane

2 Answers 67 Views
Map
This is a migrated thread and some comments may be shown as answers.
Alex Fioletov
Top achievements
Rank 1
Alex Fioletov asked on 04 Nov 2011, 10:06 PM
Good afternoon,

I have an issue with map control and Bing provider. Map is located in RadPane that is unpinned on start.
When pane is open there are no tiles, the map is just empty.

If you pin the pane and reset provider to map control you'll see the map. But unpin it again and change provider - map disappears again.

Can you suggest any workaround for this issue?

I put sample solution here https://a1optimize.accellos.com/MapinPane.rar
Just change VE key in code to reproduce issue.

Best regards,
Alex Fioletov

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 09 Nov 2011, 09:02 AM
Hi Alex Fioletov,

Thank you for the sample solution.
We have reproduced the problem. When the map control is used inside the RadPane that is unpinned on start then at start it is loaded and then it is unloaded very quickly. The map control cannot initialize the map provider correctly in this case.
I would recommend to use the Loaded and Unloaded events to set the map provider. The sample code is below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.Map;
 
namespace Map_in_Pane
{
    public partial class MainPage : UserControl
    {
        const string VEKey = "YOUR VE KEY";
 
        BingMapProvider bing = new BingMapProvider(MapMode.Road, true, VEKey);
        OpenStreetMapProvider osm = new OpenStreetMapProvider();
 
        MapProviderBase currentProvider;
 
        bool firstInitialize;
 
        public MainPage()
        {
 
            InitializeComponent();
 
            currentProvider = bing;
 
            radMap.Unloaded += new RoutedEventHandler(radMap_Unloaded);
            radMap.Loaded += new RoutedEventHandler(radMap_Loaded);
        }
 
        private void radMap_Unloaded(object sender, RoutedEventArgs e)
        {
            if (!firstInitialize)
            {
                radMap.Provider = null;
                firstInitialize = true;
            }
        }
 
        private void radMap_Loaded(object sender, RoutedEventArgs e)
        {
            // set current provider
            radMap.Provider = currentProvider;
        }
 
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            currentProvider = bing;
            this.UpdateProvider();
        }
 
        private void UpdateProvider()
        {
            // set current provider if the RadMap is displayed
            if (radMap.ActualWidth > 0)
            {
                radMap.Provider = currentProvider;
            }
        }
 
        private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            currentProvider = osm;
            this.UpdateProvider();
        }
    }
}

Best wishes,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Alex Fioletov
Top achievements
Rank 1
answered on 09 Nov 2011, 04:27 PM
Спасибо! :)
Tags
Map
Asked by
Alex Fioletov
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Alex Fioletov
Top achievements
Rank 1
Share this question
or