免费视频|新人指南|投诉删帖|广告合作|地信网APP下载

查看: 3365|回复: 0
收起左侧

MapX常见问题解答

[复制链接]

2072

主题

100000万

铜板

363

好友

地信专家组

每一次的分离都是为了下一次的相聚

Rank: 14Rank: 14Rank: 14Rank: 14

积分
17622

精华勋章宣传勋章爱心勋章组织勋章地信元老灌水勋章荣誉会员勋章活跃勋章贡献勋章

发表于 2009-11-15 16:16 | 显示全部楼层 |阅读模式
MapX常见问题解答
MapX常见问题解答  [相关论题]|  |  |   


1.对栅格图象的支持。
在mapx3.0中对对栅格图象的支持很弱。
            在mapx4.0中对对栅格图象的支持得到增强。支持BMP,GIF,TIF,JPG,PSD,PNG, MrSID file format (*.sid), 网格文件(*.mig)等。但是需要将这些格式的文件现存成*.TAB 才可以调用。
3.关于 Infotip –信息提示。
1.由Map1.InfotipSupport = True设置使能Infotip.
2.由Map1.InfotipPopupDelay = 500 (millisecond)设置延迟时间。
3.由LabelProperties .DataField来设置用做InfoTip的字段
4.如何在MapX下读取属性值。
有三种方法:
1. 由Layer对象的KeyField属性来设立要读取属性值的字段名。
接着,由Feature对象的keyValue读取此行的属性值。
2. 将图层加入到Datasets,  由Dataset对象的Value(x,y)属性,通过设置行号,列号来获得属性值。
3. 将图层加入到Datasets,之后由RowValues(ftr)获取整行的值。
        Dim ds As MapXLib.Dataset, lyr As MapXLib.layer
        Dim ftrs As Features
Dim ftr As Feature
Dim rv As RowValue
Dim rvs As RowValues
Dim DsName As String   ‘数据集名
Dim DsRows As Long, DsCols As Long
Dim i As Long, j As Long
    Set ds = Formmain.Map1.Datasets.Item(DsName)
    Set lyr = ds.layer
     
    Set ftrs = lyr.AllFeatures
     
    DsCols = ds.Fields.Count
    DsCols = DsCols + 1
    DsRows = ftrs.Count
    Grid1.Rows = DsRows + 1
    Grid1.Cols = DsCols
     
    Grid1.Row = 0
    For i = 0 To DsCols - 1
      Grid1.Col = i
      Grid1.Text = ds.Fields.Item(i + 1).Name
    Next i
    Grid1.Col = DsCols - 1
    Grid1.Text = "Fkey"
    lyr.BeginAccess miAccessRead
     
    i = 1
    For Each ftr In ftrs
        Set rvs = ds.RowValues(ftr)
        j = 0
        For Each rv In rvs
          If Not IsNull(rv.Value) Then Grid1.TextArray(i * DsCols + j) = Trim(rv.Value)
          j = j + 1
        Next
        Grid1.TextArray(i * DsCols + j) = ftr.FeatureKey
        i = i + 1
    Next
    lyr.EndAccess miAccessEnd     
    Set ftr = Nothing
    Set ftrs = Nothing
    Set ds = Nothing
    Set rv = Nothing
    Set rvs = Nothing
    Set lyr = Nothing
注意:BeginAccess,以及EndAccess可以明显的提高属性读取的速度。
5.关于查找。
两种方式:
1. 使用Find对象的Search方法。在mapx3.5中只能作到完全匹配查找,在MapX4.0中SearchEx方法则可以找到多个匹配的记录,其结果由 FindResult.Matches获取。详细请参看有关Find.SearchEx 方法的文档以及示例。
2. 使用Layer 对象的OBJECT.Search (strWhere)方法。其参数为SQL查询的WHERE子句。例如:
                     Set ftrs = lyr.Search("Character_Name like ""%市""" ;模糊查询
                     Set ftrs = lyr.Search("Character_Name = ""北京市""" ;
                     Set ftrs = lyrUSA.Search("TOTPOP > 1000000"
                     注意:1。字符串外加两个双引号。2。首先将图层加入数据集Datasets 才能使用查询。   
6. 自定义范围专题图
Dim ds As New MapXLib.Dataset
Dim thm As New MapXLib.Theme
Set ds = Formmain.Map1.Datasets(ToolBars.Combo2.Text)
Set thm = ds.Themes.add(0, "aa", "aa", False)
thm.Legend.Compact = False
thm.AutoRecompute = False
'thm.ComputeTheme = False
thm.DataMax = 700
thm.DataMin = 100
thm.ThemeProperties.AllowEmptyRanges = True
thm.ThemeProperties.NumRanges = 7
thm.ThemeProperties.DistMethod = miCustomRanges
thm.ThemeProperties.RangeCategories(1).Max = 150
thm.ThemeProperties.RangeCategories(1).Min = 50
thm.ThemeProperties.RangeCategories(2).Max = 250
thm.ThemeProperties.RangeCategories(2).Min = 150
thm.ThemeProperties.RangeCategories(3).Max = 350
thm.ThemeProperties.RangeCategories(3).Min = 250
thm.ThemeProperties.RangeCategories(4).Max = 450
thm.ThemeProperties.RangeCategories(4).Min = 350
thm.ThemeProperties.RangeCategories(5).Max = 550
thm.ThemeProperties.RangeCategories(5).Min = 450
thm.ThemeProperties.RangeCategories(6).Max = 650
thm.ThemeProperties.RangeCategories(6).Min = 550
thm.ThemeProperties.RangeCategories(7).Max = 750
thm.ThemeProperties.RangeCategories(7).Min = 650
'thm.ComputeTheme = True
thm.AutoRecompute = True
thm.Visible = True
7. 用MapX输出表格
用mapx直接输出图象是可以的,但是输出数据,可以有以下两种方式:
          1。输出为文本文件,然后由VB读取
          2。转换为VB中的groud
9.如何实现测距
a.//创建测距工具
     global const calculatedistance=1
     Private Sub Form_Load()
       map1.CreateCustomTool(calcilatedistance,miToolTypepoly ,microsscursor)
     End Sub
     Private Sub Distances_Click()
       map1.currenttool=calculatetool
     End Sub
b.//在mapx的PolyToolUsed事件中,
   用Distance( x1,y1,x2,y2 )计算距离,由状态条中或label显示。
Private Sub Map1_PolyToolUsed(ByVal ToolNum As Integer, ByVal Flags As Long, ByVal points As Object, ByVal bShift As Boolean, ByVal bCtrl As Boolean, EnableDefault As Boolean)
     
    Dim DisSum As Double
    Dim Dis As Double
    Dim n As Integer
    Dim pts As New MapXLib.points
    Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
         
   Set pts = points
     
    DisSum = 0
    MDIForm1.StatusBar1.Panels.Item(3).Text= Format(Str(DisSum), "#,##0.000000"
    Select Case Flags
        Case miPolyToolBegin
        Case miPolyToolInProgress
          If ToolNum = CalculateDistance Then
               For i = 1 To pts.Count - 1
                 x1 = pts.Item(i).X
                 y1 = pts.Item(i).Y
                 x2 = pts.Item(i + 1).X
                 y3 = pts.Item(i + 1).Y
                 Dis = Map1.Distance(x1, y1, x2, y2)
                 DisSum = DisSum + Dis
                 MDIForm1.StatusBar1.Panels.Item(3).Text = Format(Str(DisSum), "#,##0.000000"
               Next i
             End If
        Case miPolyToolEnd
End Select
10. printmap方法中w,h,x,y的单位:himetric unit代表什么意思
在mapx 的 printmap方法:PrintMap (hDC x, y, w, h)
之中,w,h,x,y的单位为himetric,1 himetric=0.01毫米。所以,
  Private Sub Command4_Click()
ScaleMode = 6  `设成毫米坐标系。
Printer.CurrentX = 0
Printer.CurrentY = 0
Printer.Print " "
Map1.PrintMap Printer.hDC, 0, 0, Map1.Width * 100, Map1.Height * 100  ‘ 1毫米=100 himetric
Printer.NewPage ` Send new page.
Printer.EndDoc  ` Printing is finished.
Exit Sub
11.关于UserDrawLayer.
UserDrawLayer允许用户画自定义格式的图形。如用户自定义的比例尺,图例,或标注。
                改变时,使用Refresh刷新
16.ACESS数据库存在点位数据,在PRO中地图化后,生成TAB表,加入MAPX,能否当数据库数据增加后反映到地图点位的刷新。
1。不要使用在PRO中下载的表文件,而使用Layerinfo对象的miLayerInfoTypeServer为数据创建点位。 程序如下:
      Private Sub LinkODBC_Click()
       Dim LayerInfo As New MapXLib.LayerInfo
       LayerInfo.Type = miLayerInfoTypeServer
       LayerInfo.AddParameter "name", “ODBCLayer”
  ’ Mapstats为Mapstats.mdb的ODBC数据源
       LayerInfo.AddParameter”connectstring",“Mapstats”
       LayerInfo.AddParameter "query",”Select * from Us_cust”
       LayerInfo.AddParameter "cache", “on”
       LayerInfo.AddParameter "MBRSearch", “on”
       LayerInfo.AddParameter "toolkit", "ODBC"   
       layerinfo.AddParameter "AutoCreateDataset", 1
       layerinfo.AddParameter "datasetname", “us_cust”
       Set lyr = Formmain.Map1.Layers.Add(LayerInfo, 1)
     End Sub
     要求:mapstats的数据已经地图化,并加入DATASETS。
      2。当数据库数据改变(增加,删除),使用Dataset的refresh方法完成点位的刷新。
18.使用MAPXTREME开发,查找的结果如何高亮显示。
程序如下:
      sub locateobj()
  dim k,lay
dim layer,findds,foundobj,bResult
k=trim(session("key")  ‘session("key"为要查的ID
lay=session("layer"    'session("layer"为当前层
set layer=Session(SESN_MAPPER).Layers(lay)
set findds=Session(SESN_MAPPER).DataSets.Add(6,layer)
set layer.find.finddataset=findds
set layer.find.findfield=findds.fields("ID"
set foundobj=layer.find.search(k)
if (foundobj.findRC mod 10=1) then
   bResult = SetMapAutoRedraw(False)
   if Session(SESN_MAPNAME)="hb" then
                Session(SESN_MAPPER).zoom=20
             else
                Session(SESN_MAPPER).zoom=1
             end if
            Session(SESN_MAPPER).centerX=foundobj.centerX
            Session(SESN_MAPPER).centerY=foundobj.centerY    ‘可将foundobj 定位在中心
            layer.Selection.add foundobj '着亮显示
            Session(SESN_MAPPER). ExportSelection=True ‘输出选择的高亮显示
            bResult = SetMapAutoRedraw(true)
else
  Response.Write "地图上未找到该目标。"
end if
       end sub
22.执行程序:
      features.item(1).keyvalue=’XXX’
      features.item(1).update
      feature没有得到改变。
  *** 将程序修改为:
      feature=features.item(1)
      feature.keyvalue=’XXX’
      feature.update
      执行无误。
21.有关Annotation.
文本类型的注释Annotation不能旋转。
20.有关紧缩。
mapx4.5,mapx4.0不提供紧缩的功能,所以只能创建一相同结构的表,然后将数据从原表中读出,再加入到新表中,以消除黑条。(这只能在mapx4.5中完成)   
25.SymbolFont.Name与SymbolCharacter
二者皆用来定义Trutype字符集,但最好使用SymbolFont.Name。
Private Sub Command1_Click()
Dim pt As New Point ' Point object passed to the CreateSymbol method of the FFeatureFactory
Dim sty As New Style ' Style object passed to the CreateSymbol method, determines what symboltype/style...etc.
x1 = Map1.CenterX
y1 = Map1.CenterY
pt.Set x1, y1 ' Set the point for where the user clicked...
sty.SymbolFont.Name = "MapInfo Arrows"
sty.SymbolFont.Size = 48 ' set the size of the symbol to be 48...
sty.SymbolFontColor = 255 ' set color of the symbol to be red...
sty.SymbolFontHalo = True ' turn Halo effect on...
sty.SymbolFontBackColor = miColorBlue ' change the Halo color to blue
Set ftr = lyr.AddFeature(FF.CreateSymbol(pt, sty))
End Sub
另一种用来选择字符集的方法:sty.PickSymbol
27.什么时候需要为表中字段创建索引。
1.若该字段参与自动绑定时。
2.若该字段的值用Find对象的Search方法来查找时。
24.用户自定义工具创建点时,若为非地球坐标系,Toolused事件中获取的值不对。
使用用户自定义工具创建图元(点线面)时,若坐标系为非地球坐标系,则要满足:
      1。在调入geoset 或 layer后,将map1.numericcoordsys=map1.displaycoordsys
      2.设置
        Dim csys As New mapxlib.CoordSys
        csys.Set 0, , 7, , , , , , , , , , Formmain.Map1.Layers.Bounds
        Set Formmain.Map1.NumericCoordSys = csys
        Set Formmain.Map1.DisplayCoordSys = csys
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线客服
快速回复 返回顶部 返回列表