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
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
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
Could you, please, open a formal support thread and attach a small runnable application where we would be able to reproduce the problem?
Greetings,
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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.
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
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
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;
}
}
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;
}
Regards,
Martin
Telerik by Progress