阅读:38790回复:62
[DELPHI+MAPX]专栏(只允许贴码跟贴)
希望大家能互相学习,共同进步。
|
|
1楼#
发布于:2009-05-25 00:13
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em03.gif" /><img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em05.gif" /><img src="images/post/smile/dvbbs/em06.gif" /><img src="images/post/smile/dvbbs/em07.gif" /><img src="images/post/smile/dvbbs/em08.gif" />
|
|
2楼#
发布于:2007-11-02 08:06
<P>请问高手,如何利用delphi和mapx实现输出地图的功能?</P>
<P>已知两个顶点的经纬度和输出地图的比例尺.</P> <P>谢谢!</P> |
|
3楼#
发布于:2007-10-12 17:10
<P>自定义测距工具(PolyToolUsed事件)[转贴]</P>
<P><BR>//1.定义常量<BR>const<BR>MYTOOL_DISTANCE=100;</P> <P>//2.创建工具<BR>procedure TForm1.FormCreate(Sender: TObject);<BR>begin<BR>Map1.CreateCustomTool(MYTOOL_DISTANCE, miToolTypePoly,miCrossCursor, EmptyParam, EmptyParam, EmptyParam);<BR>end;</P> <P>//3.响应事件<BR>procedure TForm1.Map1PolyToolUsed(Sender: TObject; ToolNum: Smallint;<BR>Flags: Integer; const Points: IDispatch; bShift, bCtrl: WordBool;<BR>var EnableDefault: WordBool);<BR>var<BR>DisSum : Double ;<BR>i: Integer;<BR>x1, y1, x2 , y2: Double ;<BR>begin<BR>DisSum:=0;<BR>if Flags=miPolyToolInProgress then<BR>begin<BR>if ToolNum= MYTOOL_DISTANCE then<BR>begin<BR>for i:=1 to CMapXPoints(Points).Count-1 do<BR>begin<BR>x1:=CMapXPoints(Points).Item(i).X;//delphi其他版本可能是item,即换为方括号<BR>y1:=CMapXPoints(Points).Item(i).Y;<BR>x2:=CMapXPoints(Points).Item(i+1).X;<BR>y2:=CMapXPoints(Points).Item(i+1).Y;<BR>DisSum:=DisSum+Map1.Distance(x1,y1,x2,y2);<BR>end;<BR>Statusbar1.Panels[0].Text:=floattostr(dissum);<BR>end;//if<BR>end; //if<BR>end;</P> <P>//4.调用工具<BR>procedure TForm1.cmdDistanceClick(Sender: TObject);<BR>begin<BR>map1.CurrentTool :=MYTOOL_DISTANCE;<BR>end;</P> <P>可惜我总是出错</P> |
|
4楼#
发布于:2007-09-12 10:35
<P>//对查找到的图元,进行字段读取/修改<BR>Var<BR> lyr : CMapXLayer;<BR> finds: CMapXFeatures;<BR> i,j:integer;<BR> rv: CMapxRowvalue;<BR>rvs: CMapxRowvalues;<BR>ds:CMapxDataset;</P>
<P>begin</P> <P> lyr:=map1.Layers.Item[edit1.text];<BR> DS:=map1.DataSets.Add(miDatasetLayer,lyr,emptyparam,emptyparam, emptyparam,emptyparam,emptyparam,emptyparam);<BR> finds:=lyr.Search('city="'+edit3.Text+'"',emptyparam);<BR> i:=finds.Count;<BR> while (i>0) do<BR> begin<BR> map1.ZoomTo(strtofloat(edit4.text),finds.Item[1].CenterX, finds.Item[1].CenterY);<BR> lyr.Selection.Replace(finds);</P> <P><BR> rvs:=ds.Rowvalues[finds.Item];<BR> for j:=1 to ds.Fields.Count do<BR> begin<BR> showmessage(rvs.Item[j].value);<BR> end;</P> <P> rvs.Item[1].value:=99; //为第一个字段赋值(本例图元有三个属性)<BR> rvs.Item[2].value:='bbb';//为第二个字段赋值<BR> rvs.Item[3].value:='cccc';//为第三个字段赋值</P> <P><BR> finds.Item.Update(true,rvs);<BR> i:=i-1;</P> <P> end;<BR> if finds.Count=0 then showmessage('没找到');<BR>end;</P> |
|
5楼#
发布于:2007-04-24 21:26
<BR> m_FlowPenTool:=TFlowPen.Create; <BR> m_FlowPenTool.CreateFlowPenTool(Map1); <BR><BR>Map1.CurrentTool:=m_FlowPenTool.GetToolNum(); <BR><BR>
|
|
6楼#
发布于:2006-04-24 21:57
各位大侠,我现在用mapx开发一个显示实时雨量信息的程序,程序每小时刷新一次,对有雨的站点,显示为下雨的图片,并且显示具体的数据,我用下面的方法来实现:<BR> lyr :=Map1.Layers.Item['rain'];<BR> lyr.KeyField:='id';<BR> //把查找的图层的值给一个图层<BR> ds := map1.Datasets.Add(miDataSetLayer, lyr ,EmptyParam, EmptyParam, EmptyParam, EmptyParam,<BR> EmptyParam, EmptyParam); //向地图的数据集中加入查找到的图层<BR> lyr.Find.FindDataset := ds; //字段数据集<BR> lyr.Find.FindField := ds.Fields.Item[2];//数据集字段<BR> str := Format('%s',['99876']); //要查找的id号<BR> ft := lyr.Find.Search(str,EmptyParam);//找到的图元 (如果找到两个的话就有问题)<BR> ftt:=ft.Layer.GetFeatureByID(ft.FeatureID );<BR> X:=ftt.CenterX;<BR> Y:=ftt.Centery;<BR> map1.Annotations.AddSymbol(x,y).Graphic.Style..SymbolBitmapName:='LITE1-32.bmp' ;//LITE1-32.bmp文件在C:\Program Files\MapInfo\MapX 5.0\CUSTSYMB目录下<BR>程序运行没问题,可是总不能显示为我要的图片,而是缺省的样式。<BR>想问一下:<BR> 1、 如果实现在Annotations上显示自定义图片?<BR> 2、 如果不能实现,有没有其他的方法。<BR> 3、 我的目标是:在查找的图元上显示一个自定义图片和相关的数据,并且能刷新。<BR> 4、 另外显示文字的时候,文字的大小好象随着图片的方法和缩小而变化,能让它不变大变小吗?map1.Annotations.AddText('89.10',X,Y,miPositionTC).Graphic.Style.TextFontColor :=clred//89.10往往会覆盖在标注的图片上,并且随图片放大而放大。
|
|
7楼#
发布于:2006-04-14 16:18
<P>procedure TForm1.Button1Click(Sender: TObject);<BR>var<BR> Ftr :feature;<BR> pts1:points;<BR> pt:point;</P>
<P>begin<BR> Ftr.Attach(Map1);<BR> Ftr.Type_:= miFeatureTypeLine;</P> <P> // Make a new region feature with two triangles<BR> pt.Set_(Map1.CenterX + 10, Map1.CenterY);<BR> pts1.Add(pt,emptyparam);<BR> pt.Set_(Map1.CenterX + 10, Map1.CenterY + 5);<BR> pts1.Add(pt,emptyparam);<BR> pt.Set_(Map1.CenterX + 15, Map1.CenterY);<BR> pts1.Add(pt,emptyparam);<BR> pt.Set_(Map1.CenterX + 20, Map1.CenterY);<BR> pts1.Add(pt,emptyparam);</P> <P> // Add the two triangles to the new region<BR> Ftr.parts.add(pts1);<BR> //ftr:=map1.FeatureFactory.CreateLine(pts1,emptyparam);<BR> //map1.Layers.Item(1).addfeature(ftr,emptyparam);</P> <P><BR> //Add the region to a temporary layer<BR> Map1.Layers.Item(1).addfeature(Ftr,emptyparam);<BR>end;<BR>为什么会出现错误/,用同样的方法在vb中就能实现????</P> <P>请高手解答!!Ftr.Attach(Map1);会出错,为什么,<BR></P> |
|
8楼#
发布于:2006-02-09 20:59
<P>procedure TForm1.Map1ToolUsed(ASender: TObject; ToolNum: Smallint; X1, Y1,<BR> X2, Y2, Distance: Double; Shift, Ctrl: WordBool;<BR> var EnableDefault: WordBool);<BR>var<BR> pt:CMapXPoint;<BR> Lyr:CMapXLayer;<BR> ftr:CMapXFeature;<BR> feaFac:CMapXFeatureFactory;<BR> newStyle:CMapXStyle;<BR>begin<BR> //邦定<BR> lyr:=Map1.Layers['China Major cities'];<BR> feaFac:=map1.FeatureFactory;<BR> //设置点对象样式<BR> newstyle:=CoStyle.Create;<BR> newstyle.SymbolType:=miSymbolTypeBitmap;<BR> newstyle.SymbolBitmapSize:=24;<BR> newstyle.SymbolBitmapTransparent:=false;<BR> newstyle.SymbolBitmapName:='YIEL2-32.BMP';<BR> //禁止自动刷新<BR> Map1.AutoRedraw:=false;<BR> //置当前图层为可写状态<BR> lyr.Editable:=true;<BR> //创建点对象<BR> pt:=CoPoint.Create;<BR> pt.Set_(map1.CenterX,map1.CenterY);<BR> //添加进当前图层<BR> ftr:=feafac.CreateSymbol(pt,NewStyle); //创建符号<BR> ftr:=feafac.CreateSymbol(pt,map1.DefaultStyle);<BR> //添加<BR> lyr.AddFeature(ftr,EmptyParam);<BR> lyr.Refresh;<BR> map1.AutoRedraw:=true;<BR> lyr.Editable:=false;<BR> //释放<BR> pt._Release;<BR>end;</P>
<P>出现"指定图层为只读图层,只读图层不可编辑”的错误是怎么回事?</P> |
|
9楼#
发布于:2005-12-05 17:10
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
上一页
下一页