1、简单专题图的显示 MapControl1.Map.Clear(); MapGeosetLoader gl=new MapGeosetLoader(@"F:/test.gst"); MapControl1.Map.Load(gl);//打开地图 MapControl1.Map.Load(new MapTableLoader(@"F:/test.tab"));//打开test.tab地图文件 FeatureLayer lyrPnt=MapControl1.Map.Layers["test"] as FeatureLayer; RangedTheme thm = new RangedTheme(lyrPnt,"PH__1999","ph",3,DistributionMethod.EqualCountPerRange); lyrPnt.Modifiers.Insert(0,thm);//定义一个RangedTheme ThemeLegendFrame frame = LegendFrameFactory.CreateThemeLegendFrame("PH__1999","pp",thm); Legend legend = MapControl1.Map.Legends.CreateLegend(new Size(5,5)); legend.Frames.Append(frame);//定义一个Legend //MapControl1.Map.Adornments.Append(legend);//如果保留此句,MapControl1中将显示Legend LegendControl1.Map = MapControl1.Map; if (MapControl1.Map.Legends.Count > 0) { LegendControl1.Legend = MapControl1.Map.Legends[0]; }//在LegendControl1控件中显示Legend

2、从MapX到MapXtreme2004[1]-工具选择在Mapx中为控件选择工具比较迅速,也很直观,如下: Map1.CurrentTool = miZoomInTool   miZoomInTool是个枚举量,指定给CurrentTool属性即可,而且象在VB中,直接在等号之后就把备选项就列出来了,非常容易。  在MapXtreme中,这个不起眼的问题却搞得有点麻烦,主要是架构有点变化,设置位置很容易找 MapControl1.MapTools.CurrentTool=  可是,要赋的值却比较麻烦,因为C#中并没有给出智能提示,而且在帮助和对象浏览器中也没有找到什么枚举值。帮助中说要赋String类型,试着 MapControl1.MapTools.CurrentTool="ZoomInMapTool";   但是出错。于是查找帮助,了解MapXtreme中的架构,大致如此:MapTools属于MapControl控件的工具集合,其中已经包含了10个工具,debug中挨个求出如下: 0:ZoomInMapTool 1:ZoomOutMapTool 2:PanMapTool 3:CenterMapTool 4:PointSelectionMapTool 5:RadiusSelectionMapTool 6:RectangleSelectionMapTool 7:PolygonSelectionMapTool 8:DistanceMapTool 9:InfoMapTool   但是要选择工具,却不能用Index,也不能用某项的名字字符串,必须用toolname属性,而且必须这样 MapControl1.MapTools.CurrentTool =ZoomInMapTool.Toolname;   因为Toolname是一个静态属性,所以必须用类名来引用,其他别的方式都不行。  看来,以后要用哪个工具,得先查到工具名称,然后才能指定了。

其他相关:  
1、Toolname是这几个类的特定属性,在其他的工具类中没有。  
2、如果界面中已经放置了同功能的操作控件并关联到MapControl控件,那么将会干扰到程序选择的工具。比如,既放了自带的移动控件,又有一个按钮可以设置移动工具,在点击自定义的按钮,选择移动工具时,那么,界面中的移动控件就会自动处于被按下的状态。这时,再用自定义的选择工具去设置别的功能就不管用了,怎么都是移动功能。所以,最好只要一个就行了。 
3、从MapX到MapXtreme2004[2]-图层操作 Mapx中基本的图层操作还是比较简单的,集中在对Layers和Layer的处理上,对别的没有太多要求。   在MapXtreme中,要完成类似功能,发生了一点变化,如下:  
1、图层的显示  在MapXtreme中,图层的显示控制发生了奇怪的变化,有一个IsVisible属性,但它是只读的,不能通过它来改变图层的显示。要控制图层的显示与隐藏,可以通过设置Layer.Enable来控制。  
2、图层的动态添加  代码如下: Catalog _catalog=MapInfo.Engine.Session.Current.Catalog; MapInfo.Data.Table _tempTable=null; Map _map=MapControl1.Map ; TableInfo ti = TableInfoFactory.CreateTemp("临时"); _tempTable = _catalog.CreateTable(ti); _map.Layers.Insert(0, new FeatureLayer(_tempTable));   
可以看出:加图层实际就是加表;Catalog对象统管表的加载以及列举;  
查帮助还可以了解:表信息其实还可以包括表的类型和坐标系。类型是指原生表,文本,access ...   
上面的ti也可以这样取得,但是,上面的表默认是MeMTab,应该是内存中的吧。 CoordSys cs=_map.GetDisplayCoordSys(); TableInfo ti = TableInfoFactory.CreateTemp("临时",MapInfo.Data.TableType.Native,cs);

4、从MapX到MapXtreme2004[3]-搜索图元一、根据名称搜索图元   
1、Mapxtreme的架构和Mapx有所变化,Mapx中,Layer包含Features,而Mapxtreme中则不是   
2、Mapxtreme的例子中的查找,是通过Find对象来实现的,而Find对象的构造,需要指定Table和Colume,Table好办,FeatureLayer.table即可,而Colume通过FeatureLayer.table.tableinfo.colums["列名"]来指定。但是,关键问题,大多数的地图,并未设计过多的字段来供查询,查的其实就是个标题和label而已。   
3、要用笨办法,遍历图层的features,通过这个方法 foreach(Feature feature in lyr.table) { }   
4、Feature派生自Object,包含一个Geometry属性,这个属性是各种几何图形对象的基类    Geometry classes that derive from FeatureGeometry include: Point, MultiPoint, MultiCurve, MultiPolygon, FeatureGeometryCollection, Rectangle, RoundedRectangle, Ellipse, LegacyArc, and LegacyText.   
5、通过如下方式引用feature对象 ((MapInfo.Geometry.LegacyText)feature.Geometry).Caption

二、通过search方法搜索   

1、catalog的search方法可以按条件搜索图元(第一个图元) // also uses search for feature Feature fDEU = _catalog.SearchForFeature("europe", MapInfo.Data.SearchInfoFactory.SearchWhere ("Country='DEU'"));   

2、先利用SearchInfoFactory构造一个SearchInfo对象,指定其搜索属性: SearchAll: Returns all the rows. SearchNearest: Returns the rows with table geometries that are closest to the given search point. SearchWhere: Returns the rows specified by the given where Clause. SearchWithinDistance: Returns the rows where the table geometry is contained within a buffer of the search point, rectangle or geometry. SearchWithinFeature: Returns the rows where the table geometry is contained within the search features's geometry. SearchWithinGeometry: Returns the rows where the table geometry is contained within the search geometry. SearchWithinRect: Returns the rows where the table geometry intersects the given rectangle. SearchIntersectsFeature: Returns the rows where the table geometry intersects with the search features's geometry. SearchIntersectsGeometry: Returns the rows where the table geometry intersects with the search geometry. SearchWithinScreenRadius: Creates a SearchInfo that returns the rows where the table geometry intersects a screen circle. SearchWithinScreenRect:Returns the rows where the table geometry intersects the given screen rectangle    

3、再调用search方法,将结果放到 MultiResultSetFeatureCollection IResultSetFeatureCollection   

4、或许还要设置视图 MapInfo.Engine.Session.Current.MapFactory[0].SetView(fc.Envelope);

三、通过选择工具来选择一个范围 1、需要控制选择的图层 2、选择的结果,通过MapInfo.Engine.Session.Current.Selections.DefaultSelection得到一个Selection对象 3、Selection对象,是一个IResultSetFeatureCollection的集合,每个对应一个表

4、对每一个IResultSetFeatureCollection,可以通过枚举器来遍历访问 Selection sl =MapInfo.Engine.Session.Current.Selections.DefaultSelection; IResultSetFeatureCollection fc=sl[0]; IFeatureEnumerator fn=fc.GetFeatureEnumerator(); ListBox1.Items.Clear(); while(fn.MoveNext()) if(fn.Current.Geometry.GetType().ToString()=="MapInfo.Geometry.LegacyText") ListBox1.Items.Add(((MapInfo.Geometry.LegacyText)fn.Current.Geometry).Caption);

5、从MapX到MapXtreme2004[4]-标注AutoLabel 好日子一去不复返了,原来总觉得Mapx很多地方设计得不是很自然,比如,feature和具体的feature之间的某些属性的关系,有时令人迷惑。但是,用了Mapxtreme,才感觉到Mapx的方便。真不知MapInfo怎么想的!原来的标注非常简单,layer有个autolabel属性,一设就可以了。现在呢: //James.Liu的代码 Table table = Session.Current.Catalog.OpenTable("usa.tab"); Map map = Session.Current.MapFactory.CreateEmptyMap(new Size(300, 300)); LabelLayer layer = new LabelLayer(); map.Layers.Add(layer); LabelSource source = new LabelSource(table); source.DefaultLabelProperties.Caption = "State_Name"; layer.Sources.Append(source); //我的 LabelLayer layer = new LabelLayer(); MapControl1.Map.Layers.Add(layer); LabelSource source = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable("地名")); source.DefaultLabelProperties.Caption = "f_name"; //标注用到的那个字段名称 layer.Sources.Append(source); 看Layer.Sources的架势,好像可以共用一个LabelLayer,试试,的确可以

6、从MapX到MapXtreme2004[5]-自定义工具从MapX到MapXtreme2004[5]-自定义工具 参见月光宝盒的文章http://jerry429.blogchina.com/2149736.html 参见 《MapXtreme2004_DevGuide_A4.pdf》 p155 Example 
1: Writing a Server SIde Custom Tool 自己的体会: 1、要写一个自定义的事件参数,传递需要的信息 
2、最好从一个MapTool派生新的工具类,而不要从现成的工具如点选工具派生,否则会带来很多问题。 感谢James.Liu给出的提示 http://www.mygis.com.cn/forum/dispbbs.asp?boardID=23&replyID=38340&ID=8090&skin=1 
3、创建好的自定义工具,必须先建立实例,加到MapControl的Maptools中,才能被设置为当前工具。还有一点也很重要,Maptools似乎没有Viewstate,每次postback都会还原,所有在pageload中必须每次都加入新工具。 
4、自定义工具的类型可以是多种多样,如下: To draw a rectangle: MapInfoWebRectangleStart MapInfoWebRectangleStop To process a click: MapInfoWebPointStart MapInfoWebPointStop To process panning of a map: MapInfoWebPanStart MapInfoWebPanStop To draw a circle: MapInfoWebCircleStart MapInfoWebCircleStop To draw a polyline: MapInfoWebDistanceStart MapInfoWebDistanceStop To draw a polygon: MapInfoWebPolygonStart MapInfoWebPolygonStop

7、从MapX到MapXtreme2004[6]-对Table、Feature等的理解一、Table 2004中,Table还是表,可以来自原始的mapinfo表,也可以来自数据库的二维表、文本等。Table的等价概念是feature集合,如下代码: (_tempTable as IFeatureCollection).Clear(); 当然,可以通过枚举器,来逐个访问table的行,如下: Selection sl =MapInfo.Engine.Session.Current.Selections.DefaultSelection; IResultSetFeatureCollection fc=sl[0]; IFeatureEnumerator fn=fc.GetFeatureEnumerator(); //IFeatureCollection也有GetFeatureEnumerator ListBox1.Items.Clear(); while(fn.MoveNext()) if(fn.Current.Geometry.GetType().ToString()=="MapInfo.Geometry.LegacyText") ListBox1.Items.Add(((MapInfo.Geometry.LegacyText)fn.Current.Geometry).Caption); 当然,用 foreach(Feature feature in tb) 也是毫无问题的,因而,table和结果集是等价的。

二、Feature Feature等价于表中的行。只与行有关,而与具体的图元的类型无关。换言之,Feature只是指图元对应的表行,而与图元的属性无关。 用Feature.Table可以引用到所属的表。 用Table.TableInfo可以引用到表的结构信息。 Feature具有的默认列,一般都包括obj,Mi_key,Mi_Style。obj我个人认为就是Feature对应的几何对象。用Feature.Geometry属性可以引用。 Feature.Geometry的类型是FeatureGeometry,它是各种具体图元(点线面文字...)的父类,Feature.Geometry属性所对应的,其实是具体的类。(我向这个属性赋点对象,发现没错)。 对Feature的使用,可以通过CataLog的SearchForFeature来查找,如下 MapInfo.Engine.Session.Current.Catalog.SearchForFeature("Layer1",MapInfo.Data.SearchInfoFactory.SearchWhere("MI_Key='"+strKey+"'") ) 由于ID其实并不唯一,所以,较好的查找对象是MI_Key。同时,Catalog还有其他的查找函数,如SearchNearest等。 加入Feature时,往往需要指定这些基本的信息,有多种加入方法。

MapXtreme开发(一)相关推荐

  1. mapxtreme开发资料全集

    为单值主题图创建自定义标注 http://www.gisdn.net/forum.php?mod=viewthread&tid=295&fromuid=3 创建有范围的主题图 http ...

  2. MapXtreme开发(二)

    1.改变地图的坐标系统 使用如下方法改变地图的坐标系统 Map map = mapControl1.Map; MapInfo.Geometry.CoordSys coordSys = Session. ...

  3. Mapxtreme中的胖客户端、瘦客户端及中型客户端介绍

    /***********本人原创,欢迎转载,转载请保留本人信息*************/ 作者:wallimn 电邮:wallimn@sohu.com 博客:http://wallimn.bokee ...

  4. java知识体系介绍

    国内最牛七星级团队马士兵.高淇等11位十年开发经验专家录制 目 录 百战程序员Java1573题 2百战程序员介绍 3JavaSE编程基础 9第一章 初识Java 9阶段项目课程1 11第二章 数据类 ...

  5. 用mapXtreme Java开发web gis应用 (上)

    1.开发控件的选择目前影响较大的国外地理服务器有Mapinfo MapXtreme.MapObject.Autodesk Map Guide.ArcIMS.Argcgisserver以及国内的Supe ...

  6. 用WPF开发Mapxtreme-- 在.net 4.0 下面开发WPF mapxtreme 程序

    前面 <用WPF开发Mapxtreme> 介绍过在.net 3.5下开发Mapxtreme的WPF程序.但是在实际开发过程中用到了DevExpress的控件. 那个Ribbon和DockP ...

  7. 提供MapXtreme 2004 6.2 NCP破解文件及安装方法(已经不能提供了,等待破解最新的吧)...

    MapXtreme 2004 6.2 NCP破解文件 1.下载MapXT运行时,注意是6.2的中文版,MXTRun62SCPCHS.exe,地址:ftp://rhodes:br5732@betaftp ...

  8. C#+Mapxtreme 实现一些GIS系统基本的功能

    此程序包括了mapxtreme地图相关基本功能的演示其中包括 鹰眼地图,图层控制,发达,缩小,平移地图,地图模糊查询,中点工具,距离测量工具,面积测量工具,图元信息查看工具.适合于企业级开发,可以为您 ...

  9. MapInfo开发心得——控件篇【转】

    前阵做一个项目过程中,需要结合MapInfo进行地方展示开发,积累一点点心得与大家共享 以下所有基于MapXtreme 6.6 MapInfo提供了足够强大的WinForm地图空间,可以很方便地在VS ...

最新文章

  1. 剑指offer:数组中的逆序对
  2. python程序执行时间
  3. 基于vue,elementui的注册页面源码
  4. Centos YUM国内163源
  5. Win10+Python3.6配置Spark创建分布式爬虫
  6. showModalDialog模态对话框的使用详解以及浏览器兼容
  7. .NET组件程序设计0723
  8. Linux(CentOS)安装Node.JS和npm的两种方式(yum安装和源码安装)
  9. Codeforces Round #277 (Div. 2)
  10. hdu2586How far away ?
  11. 争夺智能化船票:如何迈出第一步 ——访百度主任科学家 毕然
  12. 妇科癌症中的肠道菌群:病因、治疗潜力
  13. photoshop中如何在6寸相纸上打印1寸照片10张2X5模式(自动填充模式)
  14. ASR项目实战-从源码开始构建Kaldi
  15. 领悟书生写论坛之类图设计
  16. 关于打开Excel显示受保护视图空白无内容的问题已解决
  17. Java 下载 Excel文件打不开
  18. 绿岛风IPO上市已过会 加大人才储备 创新管理模式
  19. 淘宝网-接口测试白皮书V0.1
  20. 用html做七巧板的方法,第一天:html、css的初步学习和制作七巧板

热门文章

  1. ASN.1笔记——语法规则与类型概述
  2. 魔幻策划手游明日方舟5月1日正式发布:明日方舟电脑版攻略提起看
  3. 10个小技巧让你战胜拖延症
  4. Java+MySQL校园网络超市系统的设计与实现 开题 论文
  5. 线程池面试题灵魂三问
  6. 2017计算机考研考什么时候,2017年考研各科考试时间
  7. Excel导入SqlServer数据库(一)
  8. 计算机手工模拟实验实验报告,计算机模拟手工实验报告标准格式.doc
  9. YACS20223月乙组——最大空方阵
  10. 实现PLC(S7-1200)的远程操控与调试