regards
ewart
7 Answers, 1 is accepted
We will add new "MapModeChanged" event in the future releases.
As workaround you can create a custom map provider class which would inherit from BingMapProvider. You should override the OnMapModeChanged method for raising an event.
The sample code of the custom provider is below.
class
CustomBingMapProvider : BingMapProvider
{
public
CustomBingMapProvider(MapMode mode,
bool
labelVisible,
string
applicationId)
:
base
(mode, labelVisible, applicationId)
{
}
/// <summary>
/// Event occurs when the mode of the map provider is changed.
/// </summary>
public
event
EventHandler MapModeChanged;
protected
override
void
OnMapModeChanged(MapMode oldMode, MapMode newMode)
{
base
.OnMapModeChanged(oldMode, newMode);
if
(
this
.MapModeChanged !=
null
)
{
this
.MapModeChanged(
this
,
null
);
}
}
}
Then having used the custom map provider class instead of BingMapProvider you should add an event handler to your application like this:
public
MainPage()
{
InitializeComponent();
// load "mode" and "labelVisible" settings
// ...
CustomBingMapProvider provider =
new
CustomBingMapProvider(mode, labelVisible,
"BING KEY"
);
provider.MapModeChanged +=
new
EventHandler(provider_MapModeChanged);
this
.radMap.Provider = provider;
}
private
void
provider_MapModeChanged(
object
sender, EventArgs e)
{
MapProviderBase provider = (MapProviderBase)sender;
// save settings
// provider.Mode;
// provider.IsLabelVisible;
}
Regards,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
at the moment i find the event is raised twice, and also my map_initialise is fired twice when I change the event through the UI (am using the telerik MapCommandBar defined seperately from the radmap in my situation. weird - I may experiment with a small test project to see if it's something strange I'm doing.
cheers
ewart.
Thank you for the feedback.
Unfortunately we cannot reproduce the case when the MapModeChanged event occurs twice.
The RadMap.InitializeCompleted event occurs when the BingMapProvider has retrieved necessary data for initializing from WCF service.
It occurs once when the map mode is changed to Aerial or Road mode first time. Also it occurs when the label visible flag is changed first time for any mode.
The bird's eye mode raises the InitializeCompleted event each time the scene of 3D projection is changed. There is a problem in this mode. If it has been used, then it continues to refresh scenes data also for any other mode.
Sincerely yours,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I was hooking it like so:
provider.MapModeChanged += new EventHandler<MapModeChangedEventArgs>(provider_MapModeChanged);
The current documentation on silverlight does not include the Q1 2011 backwards compatibility/change section so it's real hard to know whats changed (other than the new build errors of course!)
Also, on a similar note I can no longer init OpenStreetMapProvider like this (where providerMode is MapMode),
provider = new OpenStreetMapProvider( providerMode, true);
The whole code being:
// Determine which provider to use
switch
(mapProvider)
{
case
MapProvider.OpenStreetMap: provider =
new
OpenStreetMapProvider( providerMode,
true
);
break
;
default
: provider =
new
BingMapProvider( providerMode,
true
, _bingMapKey);
break
;
}
// Set the provider of the map
this
.radMap.Provider = provider;
provider.MapModeChanged +=
new
EventHandler<MapModeChangedEventArgs>(provider_MapModeChanged);
Any ideas?
cheers
ewart
For information about changes of the Q1 2011, please, take a look to the release history:
http://www.telerik.com/products/silverlight/whats-new/release-history/q1-2011-version-2011-1-0315.aspx
Please see the following topic of RadMap: "Custom map provider architecture is not backwards compatible with previous versions".
The map providers architecture is not backwards compatible with previous versions. Unfortunately the documentation is not updated yet but should be online later this week.
Currently the map mode is supported for Bing map provider only. The OpenStreet provider has not Aerial or Road modes. The OpenStreet (like many other providers) site even have not analogs for the "mode" term. They have two renderers: Mapnik and Osmarenderer.
You can use the SetMapSource method of the map provider to set certain source like to the following:
var provider =
new
OpenStreetMapProvider();
provider.SetMapSource(
typeof
(Telerik.Windows.Controls.Map.OpenStreetOsmarenderSource).FullName);
Currently every provider has own set of the commands are shown in the command bar. They are listed in the "Commads" property of the map provider. The buttons for commands are displayed automatically when the provider is assigned to the map control.
The MapModeChanged event no longer exists. We are sorry. Currently the map control does not contain appropriate event in new architecture. We have created the PITS issue to implement the MapSourceChanged event instead of MapModeChanged. It will be available in the MapProviderBase class in nearest internal build.
You can track it using the following link:
http://www.telerik.com/support/pits.aspx#/public/silverlight/5187
Best wishes,
Andrey Murzov
the Telerik team
the mapmodechanged event missing really screws me, hopefully that can be a priority, as well as documenting the release.
cheers
ewart
We've added the MapSourceChanged event to MapProviderBase already. The fix should be available in the nearest internal build.
Kind regards,
Andrey Murzov
the Telerik team