Draws a shape on the map using the specified symbology.
object.DrawShape ( pShape, pSymbol ) |
- pShape
- Required. A variable declared as a Geometric object.
- pSymbol
- Required. A variable declared as a Symbol object.
The DrawShape method draws the shape to the current map view. If the map is refreshed or the extent changes, the shape disappears.
When the DrawShape method is called, the shape is drawn directly onto the device context instead of into the drawing cache. If you need to clear the screen before calling the DrawShape method, call Map.Redraw True in your script instead of Map.Refresh True. For example, the following VBScript code will draw a purple box around the selected feature. It should be called in the OnSelectionChanged event of the Map object:
Sub HighlightSelected
Dim pSymbol, pRect, pRS, pLyr
'Refresh the map
Map.Redraw True
'Get selected layer
Set pLyr = Map.SelectionLayer
If pLyr Is Nothing Then Exit Sub
'Get selected feature's extent
Set pRS = pLyr.Records
pRS.Bookmark = Map.SelectionBookmark
Set pRect = pRS.Fields.Shape.Extent
'Create a symbol
Set pSymbol = Application.CreateAppObject("Symbol")
pSymbol.LineColor = 8388736
pSymbol.LineWidth = 4
pSymbol.BackgroundMode = 2
'Draw the symbol at the selected feature's extent
Call Map.DrawShape(pRect, pSymbol)
'Free resources
Set pRect= Nothing
Set pSymbol=Nothing
Set pLyr = Nothing
Set pRS = Nothing
End Sub
When the DrawShape method is called, the shape is drawn directly onto the device context instead of into the drawing cache. If you need to clear the screen before calling the DrawShape method, call Map.Redraw True in your script instead of Map.Refresh True. For example, the following VBScript code will draw a purple box around the selected feature. It should be called in the OnSelectionChanged event of the Map object:
Sub HighlightSelected
Dim pSymbol, pRect, pRS, pLyr
'Refresh the map
Map.Redraw True
'Get selected layer
Set pLyr = Map.SelectionLayer
If pLyr Is Nothing Then Exit Sub
'Get selected feature's extent
Set pRS = pLyr.Records
pRS.Bookmark = Map.SelectionBookmark
Set pRect = pRS.Fields.Shape.Extent
'Create a symbol
Set pSymbol = Application.CreateAppObject("Symbol")
pSymbol.LineColor = 8388736
pSymbol.LineWidth = 4
pSymbol.BackgroundMode = 2
'Draw the symbol at the selected feature's extent
Call Map.DrawShape(pRect, pSymbol)
'Free resources
Set pRect= Nothing
Set pSymbol=Nothing
Set pLyr = Nothing
Set pRS = Nothing
End Sub