Development and application of "Silverlight" Bing Maps Three: Offline development of Bing Maps Silverlight control
I believe most of the friends using Bing Maps have seen the following picture, when we are developing Bing maps, it is wrong to create a bug in the following illustration that the user authorization failed to verify the error.
The disadvantage of using the Bing Maps Silverlight control development is that it defaults to using the online map data that Microsoft itself provides, and that Bing Maps Silverlight control is bound to the developer account for normal use. If the development key fill in the wrong or do not fill out the development key will appear on the diagram above the hint. In fact, this validation failure message can be blocked, and we can also use the Bing Maps Silverlight control to do our off-line (not using the Microsoft Map data, not through user development key verification) developed.
Through careful analysis can know, whether we are doing a limited or offline, in essence, there is no big difference, is the load of the map data is different, to solve the loading of different map data can be achieved through a custom tilesource. In addition to solve a problem, is not through the development of key validation in the case of how to kill the error hint layer, that is, delete or mask the error hint layer.
In actual development, we can not directly block the error message layer, only through other indirect way to deal with. A closer look at the API reveals that the Bing Maps Silverlight control's map controls have a Loaderror event in which we can move some hands and feet to kill the hateful error tip layer. The processing code for LOADERROR events can be found by reflector decompile:
private void Map_LoadingError(object sender, LoadingErrorEventArgs e)
{
if (this.loadingErrorMessage == null)
{
this.loadingErrorMessage = new LoadingErrorMessage();
base.RootLayer.get_Children().Add(this.loadingErrorMessage);
}
if (e.get_LoadingException() is UriSchemeNotSupportedException)
{
this.loadingErrorMessage.SetUriSchemeError(base.Culture);
}
else if (e.get_LoadingException() is ConfigurationNotLoadedException)
{
this.loadingErrorMessage.SetConfigurationError(base.Culture);
}
else if (e.get_LoadingException() is CredentialsInvalidException)
{
this.loadingErrorMessage.SetCredentialsError(base.Culture);
}
}