MapXtreme图元改变样式
2014-03-24 11:13
267 查看
由于项目的需要图元图层Sector需要改变某些图元的样式(需要红色AreaStyle 样式)并永久显示,网上找了很多方法都没找到。后来通过实践解决了这个问题,记录如下:
方法一:
//expression为筛选图元表达式,sector为图元图层
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere(expression);
MapInfo.Data.IResultSetFeatureCollection ifs = MapInfo.Engine.Session.Current.Catalog.Search("Sector", si);
MapInfo.Mapping.FeatureLayer featureLayer = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers["Sector"];
MapInfo.Data.Table table = featureLayer.Table;
foreach (MapInfo.Data.Feature f in ifs)
{
MapInfo.Geometry.DPoint dp = new MapInfo.Geometry.DPoint(f.Geometry.GeometricCentroid.x, f.Geometry.GeometricCentroid.y);
MapInfo.Styles.AreaStyle simpleStyle = new MapInfo.Styles.AreaStyle();
simpleStyle.Interior = new MapInfo.Styles.SimpleInterior(2, Color.Red, Color.Red, false);
MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(simpleStyle);
MapInfo.Data.Feature pointRow = new MapInfo.Data.Feature(table.TableInfo.Columns);
f.Style = compositeStyle;
//必须加上下面这两句,否则没效果
f.Geometry.EditingComplete();
table.UpdateFeature(f);
}
方法二:
//expression为筛选图元表达式,tempTableName为图层Table名称
MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
MapInfo.Data.MICommand command = connection.CreateCommand();
command
.Parameters.Add("@style", MIDbType.Style);
command .CommandText = "update " + tempTableName + " set Obj = Obj,MI_Style = @style where "+expression;
connection.Open();
CompositeStyle style = new CompositeStyle();
style.AreaStyle = new AreaStyle(new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 2, color, false), new SimpleInterior(2, color, color, true));
command.Parameters["@style"].Value = style;
command.ExecuteNonQuery();
command.Cancel();
command.Dispose();
connection.Close();
connection.Dispose();
方法一:
//expression为筛选图元表达式,sector为图元图层
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere(expression);
MapInfo.Data.IResultSetFeatureCollection ifs = MapInfo.Engine.Session.Current.Catalog.Search("Sector", si);
MapInfo.Mapping.FeatureLayer featureLayer = (MapInfo.Mapping.FeatureLayer)mapControl.Map.Layers["Sector"];
MapInfo.Data.Table table = featureLayer.Table;
foreach (MapInfo.Data.Feature f in ifs)
{
MapInfo.Geometry.DPoint dp = new MapInfo.Geometry.DPoint(f.Geometry.GeometricCentroid.x, f.Geometry.GeometricCentroid.y);
MapInfo.Styles.AreaStyle simpleStyle = new MapInfo.Styles.AreaStyle();
simpleStyle.Interior = new MapInfo.Styles.SimpleInterior(2, Color.Red, Color.Red, false);
MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(simpleStyle);
MapInfo.Data.Feature pointRow = new MapInfo.Data.Feature(table.TableInfo.Columns);
f.Style = compositeStyle;
//必须加上下面这两句,否则没效果
f.Geometry.EditingComplete();
table.UpdateFeature(f);
}
方法二:
//expression为筛选图元表达式,tempTableName为图层Table名称
MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
MapInfo.Data.MICommand command = connection.CreateCommand();
command
.Parameters.Add("@style", MIDbType.Style);
command .CommandText = "update " + tempTableName + " set Obj = Obj,MI_Style = @style where "+expression;
connection.Open();
CompositeStyle style = new CompositeStyle();
style.AreaStyle = new AreaStyle(new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 2, color, false), new SimpleInterior(2, color, color, true));
command.Parameters["@style"].Value = style;
command.ExecuteNonQuery();
command.Cancel();
command.Dispose();
connection.Close();
connection.Dispose();
相关文章推荐
- mapxtreme2005 改变选中的图元样式
- MapXtreme+ASP自定义图元样式及更新图元
- 初探GIS Mapxtreme 修改图元样式 实现图元闪烁
- mapxtreme2005 改变选中的图元样式
- mapxtreme2005 改变选中的图元样式
- 初探GIS Mapxtreme 修改图元样式 实现图元闪烁
- 初探GIS Mapxtreme 修改图元样式 实现图元闪烁
- mapxtreme2005 改变选中的图元样式
- mapxtreme2005 改变选中的图元样式
- 鼠标移动实现样式改变
- 扩展GridView控件(7) - 行的指定复选框选中时改变行的样式
- UIButton的UIButtonTypeRoundedRect样式导致按钮图象色彩发生改变
- CSS实现某元素hover时 所有兄弟节点样式改变
- jq 改变其他兄弟元素的样式
- 改变鼠标样式
- javascript判断文件大小 与type=‘file' 样式改变
- android样式学习(一) 使用selector改变来动态改变背景颜色
- android 改变全局字体样式(第三方字体包)
- 鼠标滑过改变样式JS函数
- javascript 改变html样式常用属性