阅读:3210回复:13
怎么样选择独立图元啊?
Pt.Set 0, 0
Set MobileFtr = Map1.Layers.Item(1).AddFeature(Map1.FeatureFactory.CreateSymbol(Pt, NewStyle1)) MobileFtr.Keyvalue = "A12356" Map1.Layers.Item("1").AutoLabel = True 我用这种方法在地图上建立了多个独立的图元。 现在我想用Map1.CurrentTool = miSelectTool选择这个图元。那么怎么样用鼠标点击某图元后得到该图元的Keyvalue值? |
|
1楼#
发布于:2004-02-10 18:24
那可以在TOOLUSED事件内编写程序来实现,
MAPX安装目录中有自带的事例,你可以去看看. |
|
2楼#
发布于:2004-02-10 20:56
问题就在于我不知道怎么得到这个独立图元??!!
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, EnableDefault As Boolean) Dim ftr As MapXLib.Feature Dim lyr As MapXLib.Layer Select Case ToolNum Case 1007 set ftr=? MsgBox ftr.KeyValue End Select End Sub |
|
3楼#
发布于:2004-02-11 08:27
通过图元的ID来获得
|
|
4楼#
发布于:2004-02-11 10:51
ID和KEYVALUE是并列属性。我需要上一级的OBJ。就是说怎么得到在TOOLUSED事件中得到这个Feature 对象的“句柄”,入口地址我都找不到怎么能去得到该对象的所有属性呢?
如果不是独立图元就可以这样得到FEATURE: Private Sub Map1_SelectionChanged() Dim oftrs As MapXLib.Features Set oftrs = Map1.Layers.Item(1).Selection MsgBox oftrs.Item(1).KeyValue End Sub 而独立图元是不能添加到任何集合中的所以不能用SELECTION做为桥梁得到FEATURE,怎么办呢!!!? |
|
5楼#
发布于:2004-02-12 17:24
你用如下代码试试,也可以看看MAPX的FINGD和SEARCH的相关帮助!
Dim obj As MapXLib.Feature Dim objs As MapXLib.Features Dim lyr As MapXLib.Layer Set lyr = Map1.Layers.Item(1) lyr.KeyField='name' Set objs = lyr.AllFeatures For Each obj In objs MsgBox obj.Keyvalue Next |
|
6楼#
发布于:2004-02-12 21:21
以下是引用gdmaple在2004-2-10 18:04:39的发言: I have been confused by your question. Since you have used the function CreateSymbol that created a stand-alone feature,and then added it to a layer,it is a stand-alone feature no longer!!!! It is a feature that belongs to a layer!!! |
|
|
7楼#
发布于:2004-02-12 21:25
therefore,you can add it to both features and selection.
Just try the codes that echo2003 offered you. |
|
|
8楼#
发布于:2004-02-13 12:06
thanks a lot.
|
|
9楼#
发布于:2004-02-16 11:58
Dim obj As MapXLib.Feature
Dim objs As MapXLib.Features Dim lyr As MapXLib.Layer Set lyr = Map1.Layers.Item(1) lyr.KeyField='name' Set objs = lyr.AllFeatures For Each obj In objs MsgBox obj.Keyvalue Next 上面的代码只是把所有的对象列出来,但是如何得到鼠标点到的哪一个对象呢? |
|
上一页
下一页