Bingmap for WPF control does not directly provide a map of China, but it is known through Bing map (China) that there is a map of Bing China. After some Baidu, find a solution. Add a new map layer to solve the problem. Use a new layer to overwrite the original map. The new layer displays the China map. The code solves most of the problems (the Code is as follows ):
// Map is the Bing map for WPF control.
Maptilelayer tilelayer;
Private void addtileoverlay ()
{
// Create a new map layer to add the tile overlay.
Tilelayer = new maptilelayer ();
// The Source of the overlay.
Tilesource = new tilesource ();
Tilesource. uriformat = "http://r2.tiles.ditu.live.com/tiles/r?quadkey=.png? G = 41 ";
// Add the tile overlay to the map layer
Tilelayer. tilesource = tilesource;
// Add the map layer to the map
If (! Map. Children. Contains (tilelayer ))
{
Map. Children. Add (tilelayer );
}
Tilelayer. Opacity = tileopacity;
}
The following code controls the addition and deletion of a map:
Private void btnaddtilelayer_click (Object sender, routedeventargs E)
{
// Add the tile overlay on the map, if it doesn't already exist.
If (tilelayer! = NULL)
{
If (! Map. Children. Contains (tilelayer ))
{
Map. Children. Add (tilelayer );
}
}
Else
{
Addtileoverlay ();
}
}
Private void btnremovetilelayer_click (Object sender, routedeventargs E)
{
// Removes the tile overlay if it has been added to the map.
If (Map. Children. Contains (tilelayer ))
{
Map. Children. Remove (tilelayer );
}
}