在mapx中如何将存放在文件夹中的图标文件标注在地图上 (30分)

A

agangr

Unregistered / Unconfirmed
GUEST, unregistred user!
我用delphi+mapx要实现这样一个功能,请指教:
用户已经自己制作好了表示不同地物标志的图标(如:仓库、桥梁等),
现在用户想将这些图标放到地图上相对应的位置上去,应该这么做呢,
另外对图标的格式是不是一定要bmp,ico的行吗?
我的地图是删格图配准后生成的
 
好像不支持吧
 
to agangr
mapx从那里下载的,能不能发一份给我。
 
基本功能,看一下mapx的delphi or VB的例子就可以了。
 
分那么少?
 
300分,我把源代码发给你
 
to :delphilai
分一定没问题,不过你的将源代码发给我看看先,将来还有其他问题请教呢!

 
unit uSymbolStyle;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, OleCtrls, MapXLib_TLB;

type
TfSymbolStyle = class(TForm)
panel: TScrollBox;
private
{ Private declarations }
lftr:CMapxFeature;//操作的对象;
procedure imageClick(sender:TObject);
Procedure FreeControls;

public
{ Public declarations }
procedure Enter(ftr:CMapXFeature);
end;


var
fSymbolStyle: TfSymbolStyle;

implementation

uses uMain, uInter, uFtrsList, uInfoFun;

{$R *.dfm}

procedure TfSymbolStyle.Enter(Ftr:CMapxFeature);
Const
ColCount: integer=10;
//每排10个图标
iSpace=1;//间隙
var
Bitmaps: BitmapSymbols;
i,j: Integer;
imageArr: Array of TSpeedButton;
iRow,iCol,RowCount,iCount: integer;
f, ftr:CMapxFeature;
sl:TStringList;
Ldata :Tfeature;
sel:Variant;
s:string;
begin


//===========================================================
sl:=TStringList.create;
fftrsList:=TfFtrsList.Create(application);
lftr:=ftr;
//===========================================================

{ Fill the ListBox with all of the names of the bitmap symbols
then
, the application could respond to ado
uble click in the
listbox by changing the style of some object on the map }
freeControls;
Bitmaps := CoBitmapSymbols.Create;
ShowMessage(inttostr(bitmaps.Count));
RowCount:=Round((Bitmaps.Count)/ColCount)+1;
showmessage(inttostr(rowcount));
SetLength(imageArr,Bitmaps.Count);
fSymbolStyle.width:=8+ColCount*32+ispace*2;
fSymbolStyle.Height:=27+RowCount*32+ispace*2;

For i := 1 to Bitmaps.Countdo

begin

// ListBox1.Items.Add(Bitmaps.Item(i).Name);
iRow:=Round(i/RowCount);
iCol:=Round(i mod RowCount);
imageArr[i-1]:=TSpeedButton.create(Panel);
imageArr[i-1].Name:='image'+inttostr(i);
imageArr[i-1].Parent:=TWinControl(Panel);
imageArr[i-1].Hint:=bitmaps.item(i).Name;
imageArr[i-1].ShowHint:=true;
imageArr[i-1].Glyph.LoadFromFile(CUSTOMSYMBOL_PATH+Bitmaps.Item(i).Name);
imageArr[i-1].Height:=32;
imageArr[i-1].Width:=32;
imageArr[i-1].top:=iSpace+(iRow)*32;
imageArr[i-1].Left:=iSpace+(iCol)*32;
imageArr[i-1].Cursor:=crHandPoint;
imageArr[i-1].onClick:=imageClick;
end;

self.show;

end;


procedure TfSymbolStyle.imageClick(sender:TObject);
var
Lyr:CMapxLayer;
begin


if MessageDlg('是否选择当前图标?',mtconfirmation,[mbyes,mbno],0)=mryes then

begin

if lFtr.Style.SupportsBitmapSymbols=true then

begin

try
lFtr.Style.SymbolType:=miSymbolTypeBitmap;
lFtr.Style.SymbolBitmapName:=TImage(sender).Hint;
lFtr.Style.SymbolBitmapTransparent:=true;
lFtr.Update(EmptyParam ,EmptyParam);
showmessage(lFtr.Name+'图标更新成功!');
except
showmessage('图标更新失败!');
end;

end
else

showmessage('该对象不支持图标!');
self.close;
end;


end;


Procedure TfSymbolStyle.freeControls;
var
i,iCount:Integer;
begin

iCount:=fSymbolStyle.panel.Controlcount;
for i:=iCount-1do
wnto 0do

fSymbolStyle.panel.Controls[0].Free;
end;


end.
 
注意位图必须是bmp格式的,而且大小必须是32×32大小的,否则不认得。
 
tmd
这么久了还没给分
 
接受答案了.
 
顶部