已成功添加了图元,但是想在其前面添加自定义的bmp文件。
- C# code
MapXLib.Layer tempstar_lyr; MapXLib.CoordSys coor = axMap1.DisplayCoordSys; tempstar_lyr = axMap1.Layers.CreateLayer("temp_start", Type.Missing, 100, 10, coor); tempstar_lyr.Editable = true; tempstar_lyr.Visible = true; tempstar_lyr.AutoLabel = true; tempstar_lyr.OverrideStyle = true; tempstar_lyr.Style.SymbolFontColor = 0x0000FF; tempstar_lyr.Style.SymbolType = (short)MapXLib.SymbolTypeConstants.miSymbolTypeVector; tempstar_lyr.Style.SymbolVectorSize = 20; MapXLib.Feature SymbolObj = new MapXLib.Feature(); SymbolObj.Attach(axMap1.GetOcx()); SymbolObj.KeyValue = "AAAAAAAAAAAAAAAAAAAAAAA"; SymbolObj.Point = pts; tempstar_lyr.AddFeature(SymbolObj, Type.Missing); //tempstar_lyr.Refresh(); tempstar_lyr.Editable = false;
------解决方案--------------------
axMap1.Layers.AnimationLayer = mlayer
ftr = new MapXLib.FeatureClass();
ftr.Attach(axMap1.GetOcx()); //这里是必须的
ftr.Type = MapXLib.FeatureTypeConstants.miFeatureTypeSymbol;
MapXLib.Style sty;
sty = new MapXLib.StyleClass();
//定义点图元的样式
sty.SymbolType = MapXLib.SymbolTypeConstants.miSymbolTypeBitmap;//指定为位图样式
sty.SymbolBitmapSize = 20;//指定图元大小
sty.SymbolBitmapName = "TEMP1-32.BMP";////位图文件必须放在安装目录的CUSTSYMB //文件夹下 ,一般在C:\Program Files\MapInfo\MapX 5.0\CUSTSYMB
sty.SymbolBitmapTransparent = true;//指定位图透明,和图层融为一体
sty.SymbolBitmapOverrideColor = false;
sty.SymbolFontColor = 0x08f780
ftr.Style = sty;
ftr.Point.Set(X, Y);