mapx+vb实战摘要

 
上个月去天津做这个项目,加班加点忙乎过了十一,现在项目终于完成了第一阶段,可以闲下来总结一下了。
   在做这个项目之前我只是自学了一个月的supermap,不过感觉gis这些东西都是大同小异,没什莫可怕;关键比较郁闷的是本来根本就是做.net,现在却要用vb实在太。。。算了,赶鸭子上架,不会也得会呀!    其实本人对这个实在只能称得上一知半解,学的和用的一样多,不过还是给自己和别人留下点东西吧,也许会有帮助呢:)
    1,设置地图标题(Map1.Title)样式
    在打开一个GeoSet时,会自动显示它的标题,如果你的GeoSet没有标题,它会自动添加一个标题。
    你可以设置标题的样式,显示出最完美的地图


     Map1.Title.Visible = False’是否可见
     Map1.Title.Editable = False'是否可编辑
     标题位置
    Map1.Title.x = Map1.MapScreenWidth - 50
    Map1.Title.y = 2
   是否有边界
    Map1.Title.Border = False
    是否粗体
   Map1.Title.TextStyle.TextFont.Bold = True
    字体大小
    Map1.Title.TextStyle.TextFont.Size = 15
   是否在文本周围绘制光晕
     Map1.Title.TextStyle.TextFontHalo = True
   控制文本是否显示背景色
     Map1.Title.TextStyle.TextFontOpaque = False
   是否在文本下绘制阴影
    Map1.Title.TextStyle.TextFontShadow = True

12 查找图元
   mapx查找地图上的图元有多种方法

  a, FindObj.Search
    这种方法在用的时候有局限性:数据集必须要有索引,查找的字段类型不能是10进制类型(可能还有其它的类型,忘了),否则在图上找不到。

     Set FindObj = fMainForm.Map1.Layers(LayerCombo.Text).Find
    Set FindObj.FindDataset = fMainForm.Map1.DataSets(LayerCombo.Text & " dataset")
    Set FindObj.FindField = FindObj.FindDataset.Fields(FieldCombo.Text)
    Set FoundFeature = FindObj.Search(FindText.Text)

If FoundFeature.FindRC Mod 10 = 1 Or FoundFeature.FindRC Mod 10 = 2 Then      
       fMainForm.Map1.Layers(LayerCombo.Text).Selection.Add FoundFeature
        fMainForm.Map1.AutoRedraw = False
        fMainForm.Map1.CenterX = FoundFeature.CenterX
        fMainForm.Map1.CenterY = FoundFeature.CenterY
   End If

  b,SQL语句方法

Dim ftrs As MapXLib.Features
Dim lyr As Layer
Dim i As Integer

Set lyr = fMainForm.Map1.Layers(RoadlyrName)
Dim strs As String
strs = Trim("路线编码 = " + Chr(34) + ComRoadID.List(ComRoadID.ListIndex) + Chr(34))‘在值前面加双引号如:ID="001",         观测点名称 like "%天平庄"
  Set ftrs = lyr.Search(strs)
  lyr.Selection.ClearSelection
lyr.Selection.Add ftrs
If ftrs.Count > 0 Then
fMainForm.Map1.CenterX = ftrs.Item(1).CenterX
fMainForm.Map1.CenterY = ftrs.Item(1).CenterY
End If

13显示鼠标当前的经纬度
Private Sub Map1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
      Dim MX As Double, MY As Double
      Map1.ConvertCoord x, y, MX, MY, 1
  
        Text1.Item(1).Caption = "当前位置"
        Text1.Item(2).Caption = "东经 " & Format(MX, "###0.0000") + ",北纬 " + Format(MY, "###0.0000")                
        Text1.Item(3).Caption = " 当前图层"
        Text1.Item(4).Caption = Map1.Layers(1).Name
End Sub

14自动滚屏
Private Sub Map1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If mnuMoveCenter.Checked = True Then
    If x > Map1.MapScreenWidth - 10 Then
    
    Map1.CenterX = Map1.CenterX + 0.05
    
    Map1.Refresh
    
    Else
    
    If x < 10 Then
    
    Map1.CenterX = Map1.CenterX - 0.05
    
    Map1.Refresh
    
    Else
    
    If y > Map1.MapScreenHeight - 10 Then
    
    Map1.CenterY = Map1.CenterY - 0.05
    
    Map1.Refresh
    
    Else
    
    If y < 10 Then
    
    Map1.CenterY = Map1.CenterY + 0.05
    
    Map1.Refresh
    
    End If
    
    End If
    
    End If
    
    End If
End If
End Sub


15测距和测面积
Private Sub Form_Load()
  Map1.CreateCustomTool PolyRulerToolID, miToolTypePoly, miSizeAllCursor
    Map1.CreateCustomTool PolyAreaToolID, miToolTypePolygon, miSelectRegionMinusCursor
End Sub


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)
    If ToolNum = PolyRulerToolID Then
        Dim i As Integer
        Dim DistanceSoFar As Double
        Map1.MapUnit = RulerUnit
        DistanceSoFar = 0#
        If Points.Count > 1 Then
            For i = 2 To Points.Count
                DistanceSoFar = DistanceSoFar + Map1.Distance(Points.Item(i).x, Points.Item(i).y, Points.Item(i - 1).x, Points.Item(i - 1).y)
            Next
        End If
        If flags = miPolyToolEnd Then
            'First, clear the status bar
            
            Text1.Item(4).Caption = ""
            MsgBox "距离: " & DistanceSoFar & " " & RulerUnitString
        Else
            Text1.Item(3).Caption = "距离"
             Text1.Item(4).Caption = DistanceSoFar & " " & RulerUnitString
        End If
    End If
    If ToolNum = PolyAreaToolID Then
    '面积
    
     Map1.AreaUnit = miUnitSquareKilometer
    On Error Resume Next
    Dim apolygoN As New MapXLib.Feature
    Dim ax As Double
    If (Points.Count > 2) Then
    Set apolygoN = New Feature
    Set apolygoN = Map1.FeatureFactory.CreateRegion(Points)
    ax = apolygoN.Area
    MsgBox "面积: " & ax
    End If
        
End If
End Sub

1如何修改柱状专题图的样式?
Map1.DataSets.Item(DsName).Themes("trafficflubar").Properties.Size = BarSize
Map1.DataSets.Item(DsName).Themes("trafficflubar").Properties.BarWidth = BarWidth
Map1.DataSets.Item(DsName).Themes("trafficflubar").ThemeProperties.MultivarCategories.Item(1).style.RegionColor = SmallTruck_Color
Map1.DataSets.Item(DsName).Themes("trafficflubar").ThemeProperties.MultivarCategories.Item(2).style.RegionColor = MiddleTruck_Color
Map1.DataSets.Item(DsName).Themes("trafficflubar").ThemeProperties.MultivarCategories.Item(3).style.RegionColor = BigTruck_Color

2如何修改饼状专题图的样式?
Map1.DataSets.Item(DsName).Themes("trafficflupiebar").Properties.Size = PieBarSize
'Map1.DataSets.Item(DsName).Themes("trafficflupiebar").Properties.Width = PieBarWidth
Map1.DataSets.Item(DsName).Themes("trafficflupiebar").ThemeProperties.MultivarCategories.Item(1).style.RegionColor = SmallTruck_Color
Map1.DataSets.Item(DsName).Themes("trafficflupiebar").ThemeProperties.MultivarCategories.Item(2).style.RegionColor = MiddleTruck_Color
Map1.DataSets.Item(DsName).Themes("trafficflupiebar").ThemeProperties.MultivarCategories.Item(3).style.RegionColor = BigTruck_Color
Map1.DataSets.Item(DsName).Themes("trafficflupiebar").ThemeProperties.MultivarCategories.Item(4).style.RegionColor = SmallCar_Color

3如何修改标注的样式?
Set oStyle = New MapXLib.style
        oStyle.TextFont.Size = 12
        oStyle.TextFont.Bold = True
        oStyle.SymbolFontColor = vbWhite
        oStyle.TextFontBackColor = vbBlue
        oStyle.TextFontOpaque = True
    
        Map1.Annotations.AddText(rs(showfield), lyr.Selection(1).CenterX, lyr.Selection(1).CenterY, 3).Graphic.style = oStyle
        (白字黑底)

已标记关键词 清除标记
相关推荐
<p> <b><span style="background-color:#FFE500;">【超实用课程内容】</span></b> </p> <p> <br /> </p> <p> <br /> </p> <p> 本课程内容包含讲解<span>解读Nginx的基础知识,</span><span>解读Nginx的核心知识、带领学员进行</span>高并发环境下的Nginx性能优化实战,让学生能够快速将所学融合到企业应用中。 </p> <p> <br /> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <b><br /> </b> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <b><span style="background-color:#FFE500;">【课程如何观看?】</span></b> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> PC端:<a href="https://edu.csdn.net/course/detail/26277"><span id="__kindeditor_bookmark_start_21__"></span></a><a href="https://edu.csdn.net/course/detail/27216">https://edu.csdn.net/course/detail/27216</a> </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 移动端:CSDN 学院APP(注意不是CSDN APP哦) </p> <p style="font-family:Helvetica;color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 本课程为录播课,课程永久有效观看时长,大家可以抓紧时间学习后一起讨论哦~ </p> <p style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <br /> </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <strong><span style="background-color:#FFE500;">【学员专享增值服务】</span></strong> </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> <b>源码开放</b> </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 </p> <p class="ql-long-24357476" style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;"> 下载方式:电脑登录<a href="https://edu.csdn.net/course/detail/26277"></a><a href="https://edu.csdn.net/course/detail/27216">https://edu.csdn.net/course/detail/27216</a>,播放页面右侧点击课件进行资料打包下载 </p> <p> <br /> </p> <p> <br /> </p> <p> <br /> </p>
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页