zoukankan      html  css  js  c++  java
  • 必应地图控件(WPF版)添加中国地图

    Bingmap for WPF control 没有直接提供中国地图,但是通过必应地图(中国)知道,时存在必应中国地图,经过一番百度后,找到解决办法。通过添加新的地图图层来解决问题,用新的图层覆盖原有的地图,新图层中显示中国地图。不说了,代码解决大部分问题(代码如下):

      //其中map为必应地图for WPF 控件

    MapTileLayer tileLayer;

             private void AddTileOverlay()

             {

                                // Create a new map layer to add the tile overlay to.

                                tileLayer = new MapTileLayer();

                                // The source of the overlay.

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

             }

    以下是控制地图的增加、删除代码:

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

                                }

                       }

  • 相关阅读:
    (难)Codeforces Round #406 (Div. 2) C题Berzerk(有向图博弈)解题报告
    jquery清空kindEditor
    处理用户误输入html标签引起的网站布局混乱
    自动闭合所有标签的方法,用于获得textBox等值的时候,标签都是闭合的
    .NET一个页面多个Button按钮事件避免数据验证控件RequiredFieldValidator
    基类包括字段(),但其类型()与控件()的类型不兼容
    关于ajax回调数据类型为Json,如何获得他的值
    如何查找Repeater控件中嵌套的控件
    网站功能
    WIN7系统IIS上发布站点后水印效果失效的解决方法
  • 原文地址:https://www.cnblogs.com/xiwang/p/2576727.html
Copyright © 2011-2022 走看看