阅读:1640回复:3
MapX控件,在拖动地图时会有大量的空白,怎么解决?
<P>如题~</P>
|
|
1楼#
发布于:2005-08-10 15:32
装MAPX,没有安装数据
|
|
2楼#
发布于:2005-08-10 15:39
能说明白一点吗?我是第一次做GIS。
|
|
3楼#
发布于:2005-08-13 10:42
<P>~~~~~~~~~~~~~~~~~~~~~~~</P>
<P>用Delphi实现MapX中类似AutoCAD的平滑移动的Pen工具</P> <P>//类文件 <BR>unit TFlowPenClass; </P> <P>interface <BR>uses Controls,Classes,MapXLib_TLB; <BR>type <BR> TFlowPen=Class(TObject) <BR> protected <BR> m_IriMouseMoveEvent:TMouseMoveEvent; <BR> m_IriMouseUpEvent:TMouseEvent; <BR> m_IriMouseDownEvent:TMouseEvent; <BR> m_pMap:Tmap; <BR> m_bMosueDown:Boolean; <BR> m_sPenInX:Single; <BR> m_sPenInY:Single; <BR> protected <BR> procedure MapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> procedure MapMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> procedure MapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); <BR> public <BR> Function CreateFlowPenTool(pMap:TMap):Integer; <BR> Function InstallFlowPenTool():Boolean; <BR> Function UnInstallFlowPenTool():Boolean; <BR> Function GetToolNum():Integer; <BR>end; <BR>const <BR> MAP_TOOL_FLOWPEN=1; <BR>implementation </P> <P> procedure TFlowPen.MapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> begin <BR> If (m_pMap.CurrentTool=MAP_TOOL_FLOWPEN) And (Not m_bMosueDown) Then <BR> begin <BR> m_bMosueDown:=True; <BR> m_sPenInX:=X; <BR> m_sPenInY:=Y; <BR> end; <BR> if @m_IriMouseDownEvent<>nil then <BR> m_IriMouseDownEvent(Sender,Button,Shift,X,Y); <BR> end; <BR> procedure TFlowPen.MapMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); <BR> begin <BR> If (m_pMap.CurrentTool=MAP_TOOL_FLOWPEN) And m_bMosueDown Then <BR> m_bMosueDown:=False; <BR> if @m_IriMouseUpEvent<>nil then <BR> m_IriMouseUpEvent(Sender,Button,Shift,X,Y); <BR> end; <BR>procedure TFlowPen.MapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); <BR>var <BR> dX1,dX2,dY1,dY2ouble; <BR> sX,sY:Single; <BR>begin <BR> If (m_pMap.CurrentTool=MAP_TOOL_FLOWPEN) And m_bMosueDown Then <BR> begin <BR> sX:=X;sY:=y; <BR> m_pMap.ConvertCoord(sX,sY,dX1,dY1,miScreenToMap); <BR> m_pMap.ConvertCoord(m_sPenInX,m_sPenInY,dX2,dY2,miScreenToMap); <BR> m_pMap.CenterX:=m_pMap.CenterX-(dX1-dX2); <BR> m_pMap.CenterY:=m_pMap.CenterY-(dY1-dY2); <BR> m_sPenInX:=X; <BR> m_sPenInY:=Y; <BR> End; <BR> if @m_IriMouseMoveEvent<>nil then <BR> m_IriMouseMoveEvent(Sender,Shift,X,Y); <BR>end; <BR>Function TFlowPen.CreateFlowPenTool(pMap:Tmap):Integer; <BR>begin <BR> m_pMap:=pMap; <BR> if m_pMap<>nil then <BR> begin <BR> m_pMap.CreateCustomTool(MAP_TOOL_FLOWPEN,miToolTypePoint,miPanCursor,miPanCursor,miPanCursor); <BR> InstallFlowPenTool; <BR> result:=MAP_TOOL_FLOWPEN; <BR> end <BR> else <BR> result:=-1; <BR>end; <BR>Function TFlowPen.InstallFlowPenTool():boolean; <BR>begin <BR> if m_pMap<>nil then <BR> begin <BR> m_IriMouseMoveEvent:=m_pMap.OnMouseMove; <BR> m_IriMouseUpEvent:=m_pMap.OnMouseUp; <BR> m_IriMouseDownEvent:=m_pMap.OnMouseDown; <BR> m_pMap.OnMouseMove:=MapMouseMove; <BR> m_pMap.OnMouseUp:=MapMouseUp; <BR> m_pMap.OnMouseDown:=MapMouseDown; <BR> m_bMosueDown:=False; <BR> result:=True; <BR> end <BR> else <BR> result:=False; <BR>end; <BR>Function TFlowPen.UnInstallFlowPenTool():Boolean; <BR>begin <BR> if m_pMap<>nil then <BR> begin <BR> m_pMap.OnMouseMove:=m_IriMouseMoveEvent; <BR> m_pMap.OnMouseUp:=m_IriMouseUpEvent; <BR> m_pMap.OnMouseDown:=m_IriMouseDownEvent; <BR> m_IriMouseMoveEvent:=nil; <BR> m_IriMouseUpEvent:=nil; <BR> m_IriMouseDownEvent:=nil; <BR> m_pMap:=nil; <BR> result:=True; <BR> end <BR> else <BR> result:=False; <BR>end; <BR>Function TFlowPen.GetToolNum():Integer; <BR>begin <BR> result:=MAP_TOOL_FLOWPEN; <BR>end; <BR>end. </P> <P>//使用时初试化 <BR> m_FlowPenTool:=TFlowPen.Create; <BR> m_FlowPenTool.CreateFlowPenTool(Map1); <BR>//开始使用FlowPen <BR>Map1.CurrentTool:=m_FlowPenTool.GetToolNum(); </P> <P>//MapX.RedrawInterval设置为30或更大效果会比较好</P> |
|