图元闪烁 网上资料很多都是通过清空图层内表数据,在重新添加图元新样式信息来实现,这样确实能实现图元的闪烁的效果,但总觉的怪怪的。
首先我们要明确图元闪烁只是图元的样式改变,
其次其一些基本数据无需更改,所以无需清空数据,只需更改表内数据中的图元样式以及其他信息即可,如:点位置。我们也可以通过更改点位置来实现小车动态移动闪烁功能。
通过(Timer)计时器来不断的调用此方法,来实现图元闪烁功能。
/// <summary>
/// 修改点样式
/// </summary>
/// <param name="layerName">图层名</param>
/// <param name="map">地图</param>
/// <param name="shortCode">图元Code</param>
/// <param name="color">颜色 通过改变颜色来实现闪烁效果</param>
/// <param name="obj">参数 </param>
public
void
UpdatePoint(
string
layerName, Map map,
short
shortCode, Color color,
params
object
[] obj)
{
{
//这里是自定义的临时点信息类
TempPointInfo tpi = (TempPointInfo)obj[ 0 ];
MapInfo.Mapping.FeatureLayer featureLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[layerName];
MapInfo.Data.Table table = featureLayer.Table;
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere( " 站名=' " + tpi.StationName + " ' " );
//通过查询点数据将层数据修改
Feature f = Session.Current.Catalog.SearchForFeature(table, si);
DPoint dp = new DPoint(f.Geometry.GeometricCentroid.x, f.Geometry.GeometricCentroid.y);
MapInfo.Styles.SimpleVectorPointStyle simpleVectorPointStyle = new MapInfo.Styles.SimpleVectorPointStyle(shortCode, color, 9 );
MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(simpleVectorPointStyle);
MapInfo.Data.Feature pointRow = new MapInfo.Data.Feature(table.TableInfo.Columns);
f.Style = compositeStyle;
f.Geometry.EditingComplete();
table.UpdateFeature(f);
}
TempPointInfo tpi = (TempPointInfo)obj[ 0 ];
MapInfo.Mapping.FeatureLayer featureLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[layerName];
MapInfo.Data.Table table = featureLayer.Table;
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere( " 站名=' " + tpi.StationName + " ' " );
//通过查询点数据将层数据修改
Feature f = Session.Current.Catalog.SearchForFeature(table, si);
DPoint dp = new DPoint(f.Geometry.GeometricCentroid.x, f.Geometry.GeometricCentroid.y);
MapInfo.Styles.SimpleVectorPointStyle simpleVectorPointStyle = new MapInfo.Styles.SimpleVectorPointStyle(shortCode, color, 9 );
MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(simpleVectorPointStyle);
MapInfo.Data.Feature pointRow = new MapInfo.Data.Feature(table.TableInfo.Columns);
f.Style = compositeStyle;
f.Geometry.EditingComplete();
table.UpdateFeature(f);
}