lyr := MyMap.Layers._Item('alarmdevice');  while not QueryFlash.Eof do
  begin
    str := Format('%d',[QueryFlash.FieldByName('mi_prinx').AsInteger]);
    ft := lyr.Search(' mi_prinx = ' + str, EmptyParam);
    if ft.Count <= 0 then continue;    case ft.Item[1].type_ of
    miFeatureTypeSymbol:
      begin
        //这里ft.Item[1].Style.SymbolBitmapName竟然为空串,我加载图层的时候有指定图层的SymbolBitmapName = 'AlarmDevice.BMP' 
        showmessage(ft.Item[1].Style.SymbolBitmapName);
        if ft.Item[1].Style.SymbolBitmapName = 'AlarmDevice.BMP' then
          ft.Item[1].Style.SymbolBitmapName := 'STOP1-32.BMP'
        else
          ft.Item[1].Style.SymbolBitmapName := 'AlarmDevice.BMP';
        ft.Item[1].Style.SymbolBitmapSize := 24;
        ft.Item[1].Style.SymbolBitmapName := 'STOP1-32.BMP';
        lyr.Selection.Replace(ft.Item[1]);
        ft.Item[1].Update(EmptyParam, EmptyParam);
      end;
    end;
    QueryFlash.Next;
  end;
  现在问题是更新了检索出的图元的样式,在地图上却体现不出新的样式来,请大家帮帮忙给看看。谢谢了

解决方案 »

  1.   

    你可以這樣,先查找到圖元,在進行編輯,最後再作修改動作...
    .........
    Var
       lyr : CMapXLayer;
       finds: CMapXFeatures;
       i,j:integer;
       rv: CMapxRowvalue;
    rvs: CMapxRowvalues;
    ds:CMapxDataset;begin  lyr:=map1.Layers.Item[edit1.text];
      DS:=map1.DataSets.Add(miDatasetLayer,lyr,emptyparam,emptyparam, emptyparam,emptyparam,emptyparam,emptyparam);
       finds:=lyr.Search('city="'+edit3.Text+'"',emptyparam);
       i:=finds.Count;
      while (i>0) do
      begin
          map1.ZoomTo(strtofloat(edit4.text),finds.Item[1].CenterX, finds.Item[1].CenterY);
          lyr.Selection.Replace(finds);
           rvs:=ds.Rowvalues[finds.Item[i]];
           for j:=1 to ds.Fields.Count do
           begin
            showmessage(rvs.Item[j].value);
           end;       rvs.Item[1].value:=99;  //為第一個欄位賦值(本例圖元有三個屬性)
            rvs.Item[2].value:='bbb';//為第二個欄位賦值
            rvs.Item[3].value:='cccc';//為第三個欄位賦值
            finds.Item[i].Update(true,rvs);
            i:=i-1;  end;
      if finds.Count=0 then showmessage('沒找到');
    end;
    ......... 
      

  2.   

    我通过ft := lyr.Search(' mi_prinx = ' + str, EmptyParam);已经可以查找到图元,但是更新图元的样式时不起作用,不知道怎么回事
      

  3.   

    TO 北国风光:
        您好!能把你的MAPX 5 发份给我,我下载下来的在安装时老是提示有两个文件夹找不到,且安装后找不到相关的ocx文件,在delphi中的activex页面也找不到mapx相关的控件!
         谢谢!
      

  4.   

    自己找到原因了,原来我在加载图层的时候将图层的overridestyle设置为了true,后续再修改单个图元的style就不行了。希望遇到同样问题的同学引以为戒