Mapwingis开发02(打开图层操作)

一.打开图层操作
将图层文件放入 …\bin\Debug文件夹下
在这里插入图片描述
//设置地图投影
axMap1.Projection = tkMapProjection.PROJECTION_WGS84;
//打开图层
Shapefile sf = new Shapefile();
sf.Open(Environment.CurrentDirectory + @"\tantou5.shp", null);
int handler=axMap1.AddLayer(sf, true);//定义句柄
在这里插入图片描述

在这里插入图片描述
这里利用arcgis软件进行图层绘制,图层绘制的时候地理坐标系投影选择PROJECTION_WGS84,与mapwingis自带的地图投影一致。
二.根据图层类型更换图片
1.利用arcgis打开相应的图层,更改其类型属性
在这里插入图片描述
有两种类型,分别是pip和line类型
2.在…\bin\Debug文件夹放入需要更换的图片,图片名称需要和类型一致
在这里插入图片描述
代码:

 //图标方法
            int index = sf.Table.FieldIndexByName["Type"];
            var names = new HashSet<string>();
            for (int i = 0; i < sf.Table.NumRows; i++)
            {
                names.Add((string)sf.Table.CellValue[index, i]);
            }

            string[] files = Directory.GetFiles("D:/研究生项目/辽河项目/前端架构/winform小程序/WFMDemo/NEWDemo/bin/Debug/");
            foreach (string file in files)
            {
                string name = Path.GetFileNameWithoutExtension(file);//返回图片名称的完整路径
                if (Path.GetExtension(file).ToLower() == ".png" && names.Contains(name))
                {
                    MapWinGIS.Image img = new MapWinGIS.Image();
                    if (img.Open(file, ImageType.USE_FILE_EXTENSION, true, null))
                    {
                        ShapefileCategory ct = sf.Categories.Add(name);
                        ct.Expression = "[Type] = \"" + name + "\"";
                        ct.DrawingOptions.PointType = tkPointSymbolType.ptSymbolPicture;
                        ct.DrawingOptions.Picture = img;
                    }
                }
            }
            sf.DefaultDrawingOptions.Visible = false;   // hide all the unclassified points
            sf.Categories.ApplyExpressions();
            axMap1.Redraw();

在这里插入图片描述
修改完成

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值