地图查询问题:
var
str_search,str_temp:string;
lyr : IMoMapLayer;
strings : IMoStrings;
rs : IMoRecordset;
fld ,fld2 : IMoField;
flds : IMoFields;
rect : IMoRectangle;
pt :IMoPoint; str_search:=Lb_item.items.Strings[Lb_item.itemindex];
str_temp:='地物名称='+''''+str_search+'''';
if str_temp<>'' then
begin
try
lyr:=Imomaplayer(createoleobject('Mapobjects2.maplayer'));
lyr.GeoDataset:=dc.FindGeoDataset('地物点位_企事业单位1_point.shp');
// find unique values for id field
strings := IMoStrings(CreateOleObject('MapObjects2.Strings'));
rs:=lyr.SearchExpression(str_temp);
flds := rs.fields;
fld := flds.item('ID');
rs.MoveFirst ;
while not rs.eof do
begin
fld2:=rs.Fields.Item('地物名称');
if fld2.ValueAsString = str_search then
break;
rs.MoveNext ;
end;
//创建点对象,找到字段值
Pt := IMoPoint(CreateOleObject('MapObjects2.Point'));
Pt := IMoPoint(IDispatch(fld.value));
rect:= IMoRectangle(CreateOleObject('MapObjects2.Rectangle')); rect:=mapMain.Extent;
//放大到合适位置并闪烁
mapMain.Extent := rect ;
//把选择点定位在中央
if mintMapExtent <> mcintFullExtent then
mapMain.CenterAt(pt.X,pt.Y);
mapMain.FlashShape(pt,8);
except
showmessage('没有找到符合的数据地图!');
end;
end
else
showmessage('没有符合的数据!');
end;问题 :
Pt := IMoPoint(IDispatch(fld.value)); 的值转化无效
var
str_search,str_temp:string;
lyr : IMoMapLayer;
strings : IMoStrings;
rs : IMoRecordset;
fld ,fld2 : IMoField;
flds : IMoFields;
rect : IMoRectangle;
pt :IMoPoint; str_search:=Lb_item.items.Strings[Lb_item.itemindex];
str_temp:='地物名称='+''''+str_search+'''';
if str_temp<>'' then
begin
try
lyr:=Imomaplayer(createoleobject('Mapobjects2.maplayer'));
lyr.GeoDataset:=dc.FindGeoDataset('地物点位_企事业单位1_point.shp');
// find unique values for id field
strings := IMoStrings(CreateOleObject('MapObjects2.Strings'));
rs:=lyr.SearchExpression(str_temp);
flds := rs.fields;
fld := flds.item('ID');
rs.MoveFirst ;
while not rs.eof do
begin
fld2:=rs.Fields.Item('地物名称');
if fld2.ValueAsString = str_search then
break;
rs.MoveNext ;
end;
//创建点对象,找到字段值
Pt := IMoPoint(CreateOleObject('MapObjects2.Point'));
Pt := IMoPoint(IDispatch(fld.value));
rect:= IMoRectangle(CreateOleObject('MapObjects2.Rectangle')); rect:=mapMain.Extent;
//放大到合适位置并闪烁
mapMain.Extent := rect ;
//把选择点定位在中央
if mintMapExtent <> mcintFullExtent then
mapMain.CenterAt(pt.X,pt.Y);
mapMain.FlashShape(pt,8);
except
showmessage('没有找到符合的数据地图!');
end;
end
else
showmessage('没有符合的数据!');
end;问题 :
Pt := IMoPoint(IDispatch(fld.value)); 的值转化无效
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货