Creating A Marker Symbol

Last Modified:6/9/2000

This sample demonstrates how you can create a custom marker symbol. This symbol draws the points in your layer using hollow circles.

How to use:
  1. Start ArcMap. Add a point feature layer into the map.
  2. In the Visual Basic Editor, go to Tools > References and Browse to this sample's dll, double-click it and dismiss the References dialog.
  3. Copy-paste the following procedure into the editor and run it.
    '+++ This VBA script demonstrates rendering a point featurelayer using
    '    MyMarkerSymbol that we've created earlier.
    Public Sub Test_MyMarkerSymbol()
      Dim pMSym As IMarkerSymbol
      Dim pDoc As IMxDocument
      Dim pMap As IMap
      Dim pFeatLyr As IFeatureLayer
      Dim i As Long
      Dim bFound As Boolean   ' find a point feature layer?
      Set pMSym = New CustomMarkerSymbol.MyMarkerSymbol
      pMSym.Size = 10
      Set pDoc = ThisDocument
      Set pMap = pDoc.FocusMap
      ' walks through the layers collection of the map, and finds the 1st
      ' point feature layer
      For i = 0 To pMap.LayerCount - 1
        If TypeOf pMap.Layer(i) Is IFeatureLayer Then
          Set pFeatLyr = pMap.Layer(i)
          If pFeatLyr.FeatureClass.ShapeType = esriGeometryPoint Then
            bFound = True
            Exit For
          End If
        End If
      Next i
      ' if a point feature layer is found, assign our MyMarkerSymbol to
      ' the layer's renderer.  If not, prompt the user to add a point
      ' feature layer
      If bFound Then
        Dim pRen As ISimpleRenderer
        Dim pGeoFeatLyr As IGeoFeatureLayer
        Set pGeoFeatLyr = pFeatLyr
        Set pRen = pGeoFeatLyr.Renderer
        Set pRen.Symbol = pMSym
        MsgBox "Add a point feature layer"
      End If
    End Sub
  4. Run the procedure. You should see the default marker symbol being replaced with MyMarkerSymbol.
  5. Save the ArcMap document as "MyMarkerSymbol.mxd". Exit ArcMap.
  6. Start ArcMap again and open "MyMarkerSymbol.mxd" file. You should still see the point layer rendered in MyMarkerSymbol.


Difficulty: Advanced

Visual Basic
File Description
CustomMarkerSymbol.vbp Visual Basic Project File.
MyMarkerSymbol.cls Class file demonstrating how to create a custom marker symbol.

Key CoClasses: MarkerSymbol
Key Interfaces: IMarkerSymbol, ISymbol, IClone, IPersistVariant
Key Members: IMarkerSymbol::Draw