Bug? Provider order

12 posts, 0 answers
  1. Thomas
    Thomas avatar
    4 posts
    Member since:
    Oct 2011

    Posted 30 Dec 2011 Link to this post

    Hi,
    I am currently using the map control with two TileProviders (bing and a custom one).
    The problem is that thenever I change the TiledMapSource, the layer of this provider goes to the background.
    How can I fix the order of the layers?

    For further information please habe a look at the associated post: http://www.telerik.com/community/forums/wpf/map/changing-the-map-toolbar.aspx

    Regards
    Thomas
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 04 Jan 2012 Link to this post

    Hello,

    If I understand you well - when you change the source of your custom provider - you can no longer see your provider at all. I was not able to reproduce such behavior.

    I have attached a sample project to demonstrate that changing the source does not hide the provider. In the attached project I have created a custom tiled provider and two custom tiled sources. On the click of the button the sources are being toggled and the pictures should change. The map has two providers - open street map provider and my custom provider. My provider has opacity set to 0.4 so that I can see both of them. When changing the sources - I can see both of the providers.

    Please examine the attached project and let us know if you get the same behavior as explained above. Please let us know if this is what you are trying to achieve.

    If I have not understood you correctly please try to explain again the results that you are chasing. It would be of great help to us if you send us a small project that demonstrates the issue (you need to open a support ticket to be able to do that). You can also attach some snapshots of the output that you get and of the results you are after.


    Kind regards,
    Petar Marchev
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Thomas
    Thomas avatar
    4 posts
    Member since:
    Oct 2011

    Posted 09 Jan 2012 Link to this post

    Hi Petar,
    after some toying around with the sample we could reproduce the odd behaviour then switching to the bing map provider (with correct key). The open street map provider however, which you used in your sample, works like a charm.

    Regards
    Thomas
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 12 Jan 2012 Link to this post

    Hello Thomas,

    Could you, please, open a formal support thread and attach a small runnable application where we would be able to reproduce the problem?

    Greetings,
    Andrey Murzov
    the Telerik team

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

  6. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 22 Jul in reply to Andrey Link to this post

    Was this ever fixed? We are switching to Bing Maps and have the same problem. OSM had no issues. We are using 2014.3.1202.

    Our custom provider is on top of the bing map. When the user zooms we have to provide a new source for the custom provider. Doing this brings Bing to the front (or sends the custom one to the back, not sure which). If I hide the Bing layer, then I can see my data.

  7. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 27 Jul Link to this post

    Hello Jason,

    I logged this as an issue in our feedback portal where you can track its status and vote for a fix. I also updated your Telerik points as a small gesture of gratitude for pointing us to this behavior.

    You can work this around by calling the SetMapSource() method of the BingMapProvider after you change the custom provider's map source.
    private void buttonChangeSource_Click(object sender, RoutedEventArgs e)
    {           
        var customMapProvider = this.radMap.Providers[1] as CustomTiledProvider;
        customMapProvider.ChangeSource();
         
            var bingMapProvider = this.radMap.Providers[0] as BingMapProvider;
        bingMapProvider.SetMapSource(this.GetBingMapSourceId(bingMapProvider));
    }
     
    private string GetBingMapSourceId(BingMapProvider provider)
    {
        var mode = provider.Mode.ToString().ToLowerInvariant();
        return provider.SupportedSources.FirstOrDefault(x => x.ToLowerInvariant().Contains(mode));
    }

    Regards,
    Martin
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  8. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 27 Jul in reply to Martin Link to this post

    Thanks! The workaround worked great.
  9. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 28 Jul Link to this post

    Ok, spoke too soon. I transitioned to the BingRestAerialLabelSource and this workaround does not help. It seems to work fine with the Road source and the Aerial source without labels.
  10. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 02 Aug Link to this post

    Hello Jason,

    I tested the solution from my last reply also with the aerial label source and it works on my side. Can you take a look at the attached project and let me know if I am missing something? 

    Regards,
    Martin
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  11. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 02 Aug Link to this post

    Hi Martin,

    Yes, mine is a bit different. Because my data is calculated on the fly for each zoom level and data type, I don't add the sources during construction. I create a new source everytime. I changed your code to match what I do and I see the same problem. I did change the opacity of the of the custom provider to 0.5 so that I could see both.

    The "bug" is still present but it acts differently in the sample. In my real project, changing the source causes the custom provider to disappear. In this sample, changing the source causes the custom provider to be drawn at full opacity and I can't see the bing map anymore. Again, we are using 2014.3.1202.

    public class CustomTiledProvider : TiledProvider
        {
            internal string ActiveSourceID;
            bool is123;
     
            public CustomTiledProvider()
                : base()
            {
                this.is123 = false;
                this.MapSource = new CustomTiledSource();
                this.SetupCommands();
            }
             
            public override ISpatialReference SpatialReference
            {
                get
                {
                    return new MercatorProjection();
                }
            }
     
            private void SetupCommands()
            {
                //ResourceDictionary innerResourceDictionary = new ResourceDictionary()
                //{
                //    Source = new Uri("/Telerik.Windows.Controls.DataVisualization;component/Themes/Map/OfficeBlack/Styles.xaml", UriKind.Relative)
                //};
                //DataTemplate sourceDataTemplate = innerResourceDictionary["MapSourceButton"] as DataTemplate;
     
                //this.CommandBindingCollection.Clear();
     
                //this.RegisterSetSourceCommand(
                //    typeof(CustomTiledSource),
                //    "Road",
                //    sourceDataTemplate,
                //    new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/map/road.png", UriKind.RelativeOrAbsolute),
                //    null,
                //    null);
            }
     
            internal IMapSource MapSource
            {
                get { return this.MapSources[ActiveSourceID]; }
                set
                {
                    MapSources.Add(value.UniqueId, value);
                    this.SetMapSource(value.UniqueId);
                    if (!string.IsNullOrEmpty(ActiveSourceID)) {
                        this.MapSources.Remove(ActiveSourceID);
                    }
                    ActiveSourceID = value.UniqueId;
                }
            }
     
            public void ChangeSource()
            {
                if (this.is123)
                {
                    this.MapSource = new CustomTiledSource();
                }
                else
                {
                    this.MapSource = new CustomTiledSource123();
                }
     
                this.is123 = !this.is123;
            }
        }

  12. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 04 Aug Link to this post

    Hello Jason,

    The behavior with the opacity seems as another issue in the RadMap control. To work this around you can set the Opacity of the map source manually.
    public void ChangeSource()
    {
        if (this.is123)
        {
            this.MapSource = new CustomTiledSource() { Opacity = this.Opacity };
        }
        else
        {
            this.MapSource = new CustomTiledSource123() { Opacity = this.Opacity };
        }
     
        this.is123 = !this.is123;
    }
    As a side note, I updated your Telerik points for helping us to find this behavior.

    Regards,
    Martin
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  13. Jason D
    Jason D avatar
    72 posts
    Member since:
    Jan 2011

    Posted 04 Aug in reply to Martin Link to this post

    Thanks. For whatever reason it's working perfectly now. We'll try it out for awhile to ensure it stays working, but for now this seems to be resolved.
Back to Top
UI for WPF is Visual Studio 2017 Ready