K
kitty5263
Unregistered / Unconfirmed
GUEST, unregistred user!
我在看MO自带的例子中,总是出现这个问题,麻烦各位大侠帮帮忙,我用的是delphi7.0,源代码如下:
unit Image;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, Buttons, ExtCtrls,ComObj,sample,
MapObjects2_TLB;
type
TForm1 = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Map1: TMap;
procedure Map1AfterLayerDraw(Sender: TObject;
index: Smallint;
canceled: Wordbool;
hDC: Cardinal);
procedure Map1BeforeLayerDraw(Sender: TObject;
index: Smallint;
hDC: Cardinal);
procedure Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure SpeedButton3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
sampl :Tsample;
implementation
{$R *.DFM}
{*****************************************************************************}
procedure TForm1.Map1AfterLayerDraw(Sender: TObject;
index: Smallint;
canceled: Wordbool;
hDC: Cardinal);
begin
// set default cursor
if index=0 then
Map1.MousePointer :=0;
end;
{*****************************************************************************}
procedure TForm1.Map1BeforeLayerDraw(Sender: TObject;
index: Smallint;
hDC: Cardinal);
begin
// show hourglass
if index=1 then
Map1.MousePointer:=11;
end;
{*****************************************************************************}
procedure TForm1.Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
r : IMoRectangle;
begin
if SpeedButton1.down =True then
begin
// zoom in
r := IMoRectangle(CreateOleObject('MapObjects2.Rectangle'));
r :=Map1.TrackRectangle;
[red]if not varisempty(r) then
Map1.Extent :=r;[/red]
end
else
if SpeedButton2.down =True then
// pan
Map1.Pan;
end;
{*****************************************************************************}
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
Map1.Extent :=Map1.FullExtent;
end;
{*****************************************************************************}
procedure TForm1.FormShow(Sender: TObject);
var
dc : IMoDataConnection;
mlayer : IMoMapLayer;
ilayer : IMoImageLayer;
begin
dc := IMoDataConnection(CreateOleObject('MapObjects2.DataConnection'));
dc.database :=sampl.ReturnDataPath('washington');
if not dc.connect then
exit;
// first add image layer
ilayer := IMoImageLayer(CreateOleObject('MapObjects2.Imagelayer'));
iLayer.File_ := sampl.ReturnDataPath('washington/wash.bmp');
Map1.layers.Add(iLayer);
mlayer := IMoMapLayer(CreateOleObject('MapObjects2.Maplayer'));
mlayer.Geodataset :=dc.FindGeoDataset('roads');
IMoSymbol(mlayer.Symbol).color := moYellow;//65535;
Map1.layers.Add(mLayer);
end;
end.
红色部分有问题显示为:[错误] Image.pas(68): Undeclared identifier: 'varisempty'
[致命错误] image1.dpr(6): Could not compile used unit 'Image.pas'
希望大家帮帮忙,谢谢了
unit Image;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, Buttons, ExtCtrls,ComObj,sample,
MapObjects2_TLB;
type
TForm1 = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Map1: TMap;
procedure Map1AfterLayerDraw(Sender: TObject;
index: Smallint;
canceled: Wordbool;
hDC: Cardinal);
procedure Map1BeforeLayerDraw(Sender: TObject;
index: Smallint;
hDC: Cardinal);
procedure Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure SpeedButton3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
sampl :Tsample;
implementation
{$R *.DFM}
{*****************************************************************************}
procedure TForm1.Map1AfterLayerDraw(Sender: TObject;
index: Smallint;
canceled: Wordbool;
hDC: Cardinal);
begin
// set default cursor
if index=0 then
Map1.MousePointer :=0;
end;
{*****************************************************************************}
procedure TForm1.Map1BeforeLayerDraw(Sender: TObject;
index: Smallint;
hDC: Cardinal);
begin
// show hourglass
if index=1 then
Map1.MousePointer:=11;
end;
{*****************************************************************************}
procedure TForm1.Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
r : IMoRectangle;
begin
if SpeedButton1.down =True then
begin
// zoom in
r := IMoRectangle(CreateOleObject('MapObjects2.Rectangle'));
r :=Map1.TrackRectangle;
[red]if not varisempty(r) then
Map1.Extent :=r;[/red]
end
else
if SpeedButton2.down =True then
// pan
Map1.Pan;
end;
{*****************************************************************************}
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
Map1.Extent :=Map1.FullExtent;
end;
{*****************************************************************************}
procedure TForm1.FormShow(Sender: TObject);
var
dc : IMoDataConnection;
mlayer : IMoMapLayer;
ilayer : IMoImageLayer;
begin
dc := IMoDataConnection(CreateOleObject('MapObjects2.DataConnection'));
dc.database :=sampl.ReturnDataPath('washington');
if not dc.connect then
exit;
// first add image layer
ilayer := IMoImageLayer(CreateOleObject('MapObjects2.Imagelayer'));
iLayer.File_ := sampl.ReturnDataPath('washington/wash.bmp');
Map1.layers.Add(iLayer);
mlayer := IMoMapLayer(CreateOleObject('MapObjects2.Maplayer'));
mlayer.Geodataset :=dc.FindGeoDataset('roads');
IMoSymbol(mlayer.Symbol).color := moYellow;//65535;
Map1.layers.Add(mLayer);
end;
end.
红色部分有问题显示为:[错误] Image.pas(68): Undeclared identifier: 'varisempty'
[致命错误] image1.dpr(6): Could not compile used unit 'Image.pas'
希望大家帮帮忙,谢谢了