yuzl910
路人甲
路人甲
  • 注册日期2006-04-20
  • 发帖数1
  • QQ
  • 铜币108枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2526回复:6

求教:mapx+vb 如何控制图元位置

楼主#
更多 发布于:2006-04-29 15:22
<P >晚辈用<FONT face="Times New Roman">vb+mapx</FONT>做毕业设计<FONT face="Times New Roman"> </FONT>,我想先建一个图元,然后通过<FONT face="Times New Roman">text</FONT>输入坐标来控制图元移动,可折腾了好就也没实现,恳请前辈指点,晚辈这里先谢过了!!</P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Const cartool = 1</FONT></P>
<P ><FONT face="Times New Roman">Dim st As MapXLib.Style</FONT></P>
<P ><FONT face="Times New Roman">Dim lyrmylayer As MapXLib.Layer</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Dim xpos As Double, ypox As Double</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Private Sub Command2_Click()</FONT></P>
<P ><FONT face="Times New Roman">Map1.CurrentTool = cartool</FONT></P>
<P ><FONT face="Times New Roman">End Sub</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Private Sub Command3_Click()</FONT></P>
<P ><FONT face="Times New Roman">Map1.DefaultStyle.PickSymbol</FONT></P>
<P ><FONT face="Times New Roman">End Sub</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Private Sub Command4_Click()</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">xpos = Val(Text1.Text)</FONT></P>
<P ><FONT face="Times New Roman">ypos = Val(Text2.Text)</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Map1.Layers.Item("car").Editable = True</FONT></P>
<P ><FONT face="Times New Roman">Map1.Layers.Item("car").Feature.fmapsybol.Point.Set xpos, ypos '</FONT>实时错误<FONT face="Times New Roman"> '438' </FONT>对象不支持该属性或方法</P>
<P ><FONT face="Times New Roman">Map1.Layers.Item("car").Feature.fmapsybol.Update</FONT></P>
<P ><FONT face="Times New Roman">End Sub</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">Private Sub Form_Load()</FONT></P>
<P ><FONT face="Times New Roman">Set lyrmylayer = Map1.Layers.CreateLayer("car")</FONT></P>
<P ><FONT face="Times New Roman">Set Map1.Layers.AnimationLayer = lyrmylayer</FONT></P>
<P ><FONT face="Times New Roman">Map1.CreateCustomTool cartool, miToolTypePoint, miSelectCursor</FONT></P>
<P ><FONT face="Times New Roman">Map1.Title.TextStyle.TextFont.Size = 24</FONT></P>
<P ><FONT face="Times New Roman">End Sub</FONT></P>
<P ><FONT face="Times New Roman">Private Sub map1_toolused(ByVal toolnum As Integer, ByVal x1 As Double, ByVal y1 As Double, ByVal x2 As Double, ByVal y2 As Double, ByVal distance As Double, ByVal shift As Boolean, ByVal ctrl As Boolean, enabledfault As Boolean)</FONT></P>
<P ><FONT face="Times New Roman">If toolnum = cartool Then</FONT></P>
<P ><FONT face="Times New Roman">Dim fnewsymbol As MapXLib.Feature</FONT></P>
<P ><FONT face="Times New Roman">Dim fmapsymbol As MapXLib.Feature</FONT></P>
<P ><FONT face="Times New Roman">Dim pt As New Point</FONT></P>
<P ><FONT face="Times New Roman">pt.Set x1, y1</FONT></P>
<P ><FONT face="Times New Roman">Set fnewsymbol = Map1.FeatureFactory.CreateSymbol(pt, Map1.DefaultStyle)</FONT></P>
<P ><FONT face="Times New Roman">Set fmapsymbol = lyrmylayer.AddFeature(fnewsymbol)</FONT></P>
<P ><FONT face="Times New Roman">End If</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
<P ><FONT face="Times New Roman">End Sub</FONT></P>
<P ><FONT face="Times New Roman"> <p></p></FONT></P>
喜欢0 评分0
iamcarrot_0
路人甲
路人甲
  • 注册日期2003-08-01
  • 发帖数17
  • QQ
  • 铜币167枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-05-06 17:46
<P>通过toolUsed事件捕捉地图坐标</P>
<P>建一个新的symbol删掉老的symbol</P>
举报 回复(0) 喜欢(0)     评分
echo2003
点子王
点子王
  • 注册日期2003-07-28
  • 发帖数2453
  • QQ76947571
  • 铜币5473枚
  • 威望1点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
2楼#
发布于:2006-05-08 13:53
<P>移动图元的事例代码如下</P>
<P>Dim ftr As Feature<BR>Dim MapX As Double<BR>Dim MapY As Double<BR>'convert where the mouse is clicked to the map's current coordinate system<BR>Map1.ConvertCoord X, Y, MapX, MapY, miScreenToMap<BR>'iterate through each selected feature in each layer<BR>'change the offset of the feature<BR>ftr.Offset MapX - ftr.CenterX, MapY - ftr.CenterY  'MapX 可以是你输入x值,MapY可以是你输入y值<BR>'update the feature to make the change permanent<BR>ftr.Update<BR></P>
举报 回复(0) 喜欢(0)     评分
peeter
路人甲
路人甲
  • 注册日期2006-05-11
  • 发帖数3
  • QQ
  • 铜币110枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-06-02 14:50
紧急求助啊`~`~`~我也要求教这个问题 哪位大哥能再仔细的说说啊 拜托了啊 急啊<br>
举报 回复(0) 喜欢(0)     评分
gjjofsfe
路人甲
路人甲
  • 注册日期2006-10-13
  • 发帖数3
  • QQ
  • 铜币107枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-12-07 12:44
MAPX自带的sample第一个动态图层的那个里面有代码
举报 回复(0) 喜欢(0)     评分
gis_qxz
路人甲
路人甲
  • 注册日期2005-12-03
  • 发帖数33
  • QQ
  • 铜币246枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-12-13 19:32
<P>楼主不妨试试这个思路:</P>
<P>首先,自己定义一个移动图元的工具(CUST_MOVE_FEATURE_TOOL),当该工具激发后,在ToolUsed中(或OnMouseDownInMap)捕获该工具,通过鼠标的点击坐标点获取要移动的图元,然后在OnMouseMoveInMap中处理图元移动(可参见3楼的代码),最后在OnMouseUpInMap中结束图元移动。</P>
<P>操作流程是:鼠标左键点击(OnMouseDownInMap)要移动的图元,拖动图元(OnMouseMoveInMap)到目的地,放开鼠标(OnMouseUpInMap)。</P>
举报 回复(0) 喜欢(0)     评分
whmwxhanshan123
路人甲
路人甲
  • 注册日期2006-06-17
  • 发帖数3108
  • QQ
  • 铜币6445枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2006-12-13 19:42
<img src="images/post/smile/dvbbs/em03.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em01.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部