Bing map control (WPF) adds a map of China

Source: Internet
Author: User

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

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.