在MO动态图层中添加位图VB,C#

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

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值