爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: qxsw2016

各路朋友新年好,请教高手一个问题。

[复制链接]
 楼主| 发表于 2016-2-15 14:47:20 | 显示全部楼层
bc4790ef76c6a7effa326120fffaaf51f3de6672.png 2.PNG
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-2-15 14:49:03 | 显示全部楼层
bc4790ef76c6a7effa326120fffaaf51f3de6672.png 2.PNG
密码修改失败请联系微信:mofangbao
发表于 2016-2-15 15:36:42 | 显示全部楼层
qxsw2016 发表于 2016-2-15 14:46
恕我愚笨。我要的结果是:上图是天气图的一部分,假如已经实现基于meteoinfo的按这种方式实现填图,如果 ...

在添加MapView控件时要增加ShapeSelected事件(见此贴沙发)。Demo程序里有实现此类功能的源代码,你仔细看看。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-2-16 13:37:51 | 显示全部楼层
非常感谢,我在琢磨琢磨吧。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-2-17 15:49:48 | 显示全部楼层
老师好,我又捣鼓了一下,还是没成功。我编了测试程序,窗体添加了MapView,splitContainerButton,把部分代码贴过来。
        private void Test_Load(object sender, EventArgs e)
        {
            this.Width = 1000;
            this.Height = 625;
            //Load layers
            LoadLayers();
            splitContainer1.Dock = DockStyle.Fill;
        }
        private void LoadLayers()
        {   
            //Load country layer
            string aFile = Application.StartupPath + "\\Map\\country1.shp";
            MapLayer aLayer = MapDataManage.OpenLayer(aFile);
            aLayer.LegendScheme.LegendBreaks[0].Color = Color.WhiteSmoke;
            PolygonBreak aPGB = (PolygonBreak)aLayer.LegendScheme.LegendBreaks[0];
            aPGB.DrawFill = false;
            aPGB.OutlineColor = Color.Black;
            mapView1.AddLayer(aLayer);
            //Load China layer
            aFile = Application.StartupPath + "\\Map\\china.shp";
            aLayer = MapDataManage.OpenLayer(aFile);
            aLayer.Visible = false;
            mapView1.AddLayer(aLayer);
            //Load river layer
            aFile = Application.StartupPath + "\\Map\\rivers.shp";
            aLayer = MapDataManage.OpenLayer(aFile);
            aLayer.LegendScheme.LegendBreaks[0].Color = Color.Aqua;
            ((PolyLineBreak)aLayer.LegendScheme.LegendBreaks[0]).Size = 2;
            mapView1.AddLayer(aLayer);
            //Load city layer
            aFile = Application.StartupPath + "\\Map\\CITIES.shp";
            aLayer = MapDataManage.OpenLayer(aFile);
            ((PointBreak)aLayer.LegendScheme.LegendBreaks[0]).Color = Color.Red;
            aLayer.Expanded = true;
            mapView1.AddLayer(aLayer);
            //Label city name
            VectorLayer cityLayer = (VectorLayer)aLayer;
            cityLayer.LabelSet.FieldName = "NAME";
            cityLayer.LabelSet.AvoidCollision = true;
            cityLayer.LabelSet.LabelAlignType = MeteoInfoC.Legend.AlignType.Center;
            cityLayer.LabelSet.YOffset = 0;
            cityLayer.LabelSet.LabelFont = new Font("Arial", 8);
            cityLayer.LabelSet.LabelColor = Color.Red;
            cityLayer.LabelSet.DrawShadow = false;
            cityLayer.LabelSet.ShadowColor = Color.White;
            cityLayer.LabelSet.ColorByLegend = false;
            cityLayer.AddLabels();
            mapView1.ZoomToExtent(78, 130, 16, 55);
            //layersLegend1.Refresh();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            mapView1.MouseTool = MouseTools.SelectFeatures_Rectangle;
        }
        private void mapView1_ShapeSelected(object sender, EventArgs e)
        {
            mapView1.PaintLayers();
            VectorLayer cityMapLayer = (VectorLayer)mapView1.GetLayerFromName("CITIES.shp");
            string nameStr = "Selected: ";
            for (int i = 0; i < cityMapLayer.ShapeNum; i++)
            {
               if (cityMapLayer.ShapeList.Selected)
               {
                   nameStr = nameStr + " " + cityMapLayer.GetCellValue("NAME", i).ToString() + ",";
               }
            }
            nameStr.TrimEnd(',');
            MessageBox.Show(nameStr);
        }
我这里和demo程序的主要区别是没有用到LayersLegend控件,而是直接用到mapView1.AddLayer方法。加一个button,单击后执行 mapView1.MouseTool = MouseTools.SelectFeatures_Rectangle。我也把mapView1_ShapeSelected和控件mapView1进行了关联。这时间单击站点,仍没有反映。我想问题是不是出在我没用LayersLegend、MapFrame有关。怎么解决呢?
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表