在MO動態圖層中添加位元影像VB,C#

來源:互聯網
上載者:User

C#版整理中......

VB中建立MyCustomSymbol類,引用AFCustom對象,工程-引用-瀏覽-c:/program files/Common Files/ESRI/AFCust20.tlb--開啟

'先定義一個類別模組(MyCustomSymbol,確定引用AFCustom對象)
Implements AFCustom.ICustomMarker
Private m_filename As String
Private m_dpi As Double
Private m_picture As IPicture
Public Sub SetFileName(fn As String)
    m_filename = fn
End Sub
Private Sub ICustomMarker_Draw(ByVal hDC As Long, ByVal X As Long, ByVal Y As Long)
    Dim pixWidth As Double, pixHeight As Double
    pixWidth = m_picture.Width * m_dpi / 2540
    pixHeight = m_picture.Height * m_dpi / 2540
    If Not m_picture Is Nothing Then
        m_picture.Render hDC, X - pixWidth / 2, Y + pixWidth / 2, pixWidth, -pixHeight, _
        0, 0, m_picture.Width, m_picture.Height, Null
    End If
End Sub
Private Sub ICustomMarker_ResetDC(ByVal hDC As Long)
   Set m_picture = Nothing
    End Sub
Private Sub ICustomMarker_SetupDC(ByVal hDC As Long, ByVal dpi As Double, ByVal pBaseSym As Object)
    m_dpi = dpi
    Set m_picture = LoadPicture(m_filename)
End Sub
 

Private Sub Form_Load()
 Dim bmpSym As New MyCustomSymbol
  Dim lyr As New MapLayer
  Set lyr = Map1.Layers(0)

  bmpSym.SetFileName "E:/5.bmp"

'下面三行是對於點圖層中的所有點都表示成自訂符號,With語句 對圖中點擊的點使用位元影像
  'Debug.Print Map1.Layers(0).shapeType
  'If Map1.Layers(0).shapeType = 21 Then
  '    Set lyr.Symbol.Custom = bmpSym
  With Map1.TrackingLayer.Symbol(0)
  .Custom = bmpSym
  .Size = 30
  End With
 'End If

End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set pt = Map1.ToMapPoint(X, Y)
Map1.TrackingLayer.AddEvent pt, 0
End Sub

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.