mapinfo开发 >> MapXtreme项目结构

最后编辑时间:2021年07月19日 16:41:50

【内容简介】下载好的MapXtreme源码,或者自己创建的MapXtreme源码,我们分析一下MapXtreme项目结构。

1.App_Code文件夹:自定义AppStateManager.cs类。这个了解一下就行了。
2.MapXtremeWebResources文件夹:主要有几个重要的js
Interaction.js , Command.js , Tool.js
Command.js,常用命令。
Tool.js 是在接口上控制工具,例如点击控制命令等。
3.Global.asax:主要是一些地图错误后的处理。
4.MapForm.aspx:主要的示例界面,其中拖动了地图显示控制工具控制。
后台有几个代码,主要用于访问时的初始状态管理,恢复地图显示的退出时,保存地图现在的状态。
5.Web.Config相关地图配置。



        //MapXtreme添加图层标注
        public void CreatMark()
        {
            MapInfo.Data.Table tblTemp = Cat.GetTable(tmpTableName);
            LabelSource labelSource = new LabelSource(tblTemp);   //给所创建的临时表Animation中的图元加标注
            //指定要标准字段所在的列
            labelSource.DefaultLabelProperties.Caption = "Name";     //所要标注的列名
            labelSource.DefaultLabelProperties.Layout.Offset = 8;    //标注偏移
            labelSource.DefaultLabelProperties.Layout.Alignment = MapInfo.Text.Alignment.TopRight;//标注对齐方式
            labelSource.DefaultLabelProperties.Style.Font.BackColor = System.Drawing.Color.White;        //字体背景
            labelSource.DefaultLabelProperties.Style.Font.ForeColor = System.Drawing.Color.Red;          //字体颜色
            labelSource.DefaultLabelProperties.Style.Font.TextEffect = MapInfo.Styles.TextEffect.Box;    //边缘效果
            labelSource.DefaultLabelProperties.Style.Font.FontWeight = MapInfo.Styles.FontWeight.Bold;   //粗体
            MapInfo.Styles.SimpleLineStyle simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(0);      //标注注释线
            labelSource.DefaultLabelProperties.Style.CalloutLine.ApplyStyle(simpleLineStyle);
            //取消标注注释线
            LabelLayer labelLayer = new LabelLayer();
            labelLayer.Name = "jcbz";//设置标注图层的名称
            labelLayer.Sources.Append(labelSource);//往地图中加入该标注层
            map.Layers.Add(labelLayer);
        }

或者如下代码(MapXtreme添加点):
public static void AddPoint(string layerName, DPoint dPoint, short shortCode, Color color)
     {
         MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[0];
         //得到图层
         FeatureLayer workLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[layerName];
         MapInfo.Data.Table table = workLayer.Table;
         //声明点
         FeatureGeometry point = new MapInfo.Geometry.Point(workLayer.CoordSys, dPoint);
         //点样式
         MapInfo.Styles.SimpleVectorPointStyle spsPoint = new MapInfo.Styles.SimpleVectorPointStyle(shortCode, color, 20);
         MapInfo.Styles.CompositeStyle pointStyle = new MapInfo.Styles.CompositeStyle(spsPoint);
         //创建对象
         MapInfo.Data.Feature pointRow = new MapInfo.Data.Feature(table.TableInfo.Columns);
         pointRow.Geometry = point;//必备列[图形]
         pointRow.Style = pointStyle;//必备列[图形样式]
         pointRow["index"] = new Random().Next(999);
         pointRow["value"] = "this is a point";
         //对象添加进表
         table.InsertFeature(pointRow);
     }
可以举一反三,具体了解相关代码。
 

分享到: 豆瓣 新浪微博 百度贴吧 QQ空间 QQ好友
复制链接分享给好友或者自己收藏!这里会及时更新中。。。

相关推荐:
 
QQ
QQ:278325424
咨询热线
18191066384