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

Bug? Provider order

11 Answers 82 Views
Map
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 30 Dec 2011, 08:44 AM
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

11 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 04 Jan 2012, 05:50 PM
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 >>
0
Thomas
Top achievements
Rank 1
answered on 09 Jan 2012, 09:13 AM
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
0
Andrey
Telerik team
answered on 12 Jan 2012, 08:50 AM
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 >>

0
Jason D
Top achievements
Rank 1
Veteran
answered on 22 Jul 2016, 10:44 PM

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.

0
Martin Ivanov
Telerik team
answered on 27 Jul 2016, 02:14 PM
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.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 27 Jul 2016, 02:59 PM
Thanks! The workaround worked great.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 28 Jul 2016, 09:59 PM
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.
0
Martin Ivanov
Telerik team
answered on 02 Aug 2016, 09:20 AM
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.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 02 Aug 2016, 04:08 PM

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;
        }
    }

0
Martin Ivanov
Telerik team
answered on 04 Aug 2016, 08:14 AM
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.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 04 Aug 2016, 03:38 PM
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.
Tags
Map
Asked by
Thomas
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Thomas
Top achievements
Rank 1
Andrey
Telerik team
Jason D
Top achievements
Rank 1
Veteran
Martin Ivanov
Telerik team
Share this question
or