AddPolyline method
Adds a new polyline to the map. Returns the newly created Shape object with a Type property of geoFreeform.
Applies to
Collections: Shapes
Syntax
object.AddPolyline(ArrayOfLocations)
Parameters
Part | Description |
---|---|
object | Required. An expression that returns a Shapes collection. |
ArrayOfLocations | Required Variant. An array of Location objects that forms a polyline. |
Remarks
To add a closed polygon, use the same Location object for the first and last items in the array.
To return or set the vertices after a shape is created, use the Vertices property of the Shape object.
To learn more about drawing shapes on maps, see the About using shapes in MapPoint topic.
Example
Sub AddPolylineToMap()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc(1 To 3) As MapPoint.Location
'Set up the application
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
'Get three locations and zoom in
Set objLoc(1) = objMap.FindResults("Seattle, WA").Item(1)
Set objLoc(2) = objMap.FindResults("Redmond, WA").Item(1)
Set objLoc(3) = objMap.FindResults("Tacoma, WA").Item(1)
Set objMap.Location = objLoc(1)
'Create a polyline by connecting these locations
objMap.Shapes.AddPolyline objLoc
End Sub
Note This sample code is specifically for use in MapPoint North America; it is for illustration purposes only.