gdmaple
路人甲
路人甲
  • 注册日期2004-01-14
  • 发帖数18
  • QQ
  • 铜币161枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:3210回复:13

怎么样选择独立图元啊?

楼主#
更多 发布于:2004-02-10 18:04
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值?
喜欢0 评分0
echo2003
点子王
点子王
  • 注册日期2003-07-28
  • 发帖数2453
  • QQ76947571
  • 铜币5473枚
  • 威望1点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
1楼#
发布于:2004-02-10 18:24
那可以在TOOLUSED事件内编写程序来实现,
MAPX安装目录中有自带的事例,你可以去看看.
举报 回复(0) 喜欢(0)     评分
gdmaple
路人甲
路人甲
  • 注册日期2004-01-14
  • 发帖数18
  • QQ
  • 铜币161枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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
举报 回复(0) 喜欢(0)     评分
yuance
路人甲
路人甲
  • 注册日期2004-01-29
  • 发帖数143
  • QQ
  • 铜币504枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2004-02-11 08:27
通过图元的ID来获得
举报 回复(0) 喜欢(0)     评分
gdmaple
路人甲
路人甲
  • 注册日期2004-01-14
  • 发帖数18
  • QQ
  • 铜币161枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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,怎么办呢!!!?
举报 回复(0) 喜欢(0)     评分
echo2003
点子王
点子王
  • 注册日期2003-07-28
  • 发帖数2453
  • QQ76947571
  • 铜币5473枚
  • 威望1点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
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
举报 回复(0) 喜欢(0)     评分
yesgis
路人甲
路人甲
  • 注册日期2003-12-28
  • 发帖数34
  • QQ
  • 铜币79枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2004-02-12 21:21
以下是引用gdmaple在2004-2-10 18:04:39的发言:
 Set MobileFtr = Map1.Layers.Item(1).AddFeature(Map1.FeatureFactory.CreateSymbol(Pt, NewStyle1))

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!!!
[名称]:MapInfo开发者网络
[域名]: http://www.gisdn.com
[宗旨]:新手 高手 携手 牵手
举报 回复(0) 喜欢(0)     评分
yesgis
路人甲
路人甲
  • 注册日期2003-12-28
  • 发帖数34
  • QQ
  • 铜币79枚
  • 威望0点
  • 贡献值0点
  • 银元0个
7楼#
发布于:2004-02-12 21:25
therefore,you can add it to both features and selection.
Just try the codes that echo2003 offered you.
[名称]:MapInfo开发者网络
[域名]: http://www.gisdn.com
[宗旨]:新手 高手 携手 牵手
举报 回复(0) 喜欢(0)     评分
gdmaple
路人甲
路人甲
  • 注册日期2004-01-14
  • 发帖数18
  • QQ
  • 铜币161枚
  • 威望0点
  • 贡献值0点
  • 银元0个
8楼#
发布于:2004-02-13 12:06
thanks a lot.
举报 回复(0) 喜欢(0)     评分
gdmaple
路人甲
路人甲
  • 注册日期2004-01-14
  • 发帖数18
  • QQ
  • 铜币161枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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

上面的代码只是把所有的对象列出来,但是如何得到鼠标点到的哪一个对象呢?
举报 回复(0) 喜欢(0)     评分
上一页
游客

返回顶部