
在图层中添加图元(C#+MapXtreme 6.6)猛学了一星期的MapXtreme,终于理清了头绪,任务终于可以较差了(狂喜中.......!)
在图层中插入图元是MapXtreme中经常使用的,我这里编写了一个函数,实现向某一图层中插入图元的方法:
private void DrawFeature(FeatureGeometry g, Map map, stringlayerName, short shapeCode, System.Drawing.Color col, intsize)
{
Feature f = new Feature(g, newMapInfo.Styles.SimpleVectorPointStyle(shapeCode, col, size));
MapInfo.Mapping.FeatureLayer workingLayer =(MapInfo.Mapping.FeatureLayer)map.Layers[layerName];
if (workingLayer != null)
{
workingLayer.Table.InsertFeature(f);
}
}
参数:
g:图元的几何属性
map:工作地图

layerName:工作图层,向该图层中添加图元
shapeCode:图元的形状码
col:图元颜色
size:图元大小
这样,当图元插入图层后,就可以在地图中显示出来,代码已经在.Nt2005中测试过。mapxtreme至于形状码,可以查看相关资料(实心五角星:35)。mapxtreme
Mapxtreme查看特定几个图层
假定让lyr1和lyr2两个图层充满整个地图窗口:
Table[] ts= new Table[2];
ts[0] = lyr1.Table;
ts[1] = lyr2.Table;
IMapLayerFilter iml =MapLayerFilterFactory.FilterByTable(ts);
MapLayerEnumerator mle =mapControl1.Map.Layers.GetMapLayerEnumerator(iml);
mapControl1.Map.SetView(mle);

这里很多东西都是从别的网站收集的,比如jetz的blog含金量就很高,有些东西取自,致谢~
1.图层的显示:Layer.Enable = true/false;
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));
3.图层的Selectable/Editable
WinApp&WebApp:
LayerHelper.SetSelectable( this.mapControl1.Map.Layers[0], true);
LayerHelper.SetEditable( this.mapControl1.Map.Layers[0], true);
WebApp:
mapControl1.SelectableLayers.add( mapControl1.Map.Layers[0].Alias);
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-28345-1.html
q气死人啦