Polyline Class

Note

Bing Maps Web Control SDK retirement

Bing Maps Web Control SDK is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps Web Control SDK until June 30th, 2025. Enterprise account customers can continue to use Bing Maps Web Control SDK until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps Web Control SDK will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type. For detailed migration guidance, see Migrate from Bing Maps Web Control SDK and Migrate Bing Maps Enterprise applications to Azure Maps with GitHub Copilot.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

Polylines allow you to draw connected lines on a map. In many spatial database systems, this is also known as a LineString. The Polyline class derives from the IPrimitive interface. When creating a polyline, an array of locations must be passed as an argument in the constructor. Optionally polyline options can also be passed in as an argument.

Constructor

Polyline(locations: Location[], options?: PolylineOptions)

Methods

The Polyline class has the following methods.

Name Return Type Description
getCursor() string Gets the css cursor value when the polyline has mouse events on it.
getGeneralizable() boolean Returns whether the polyline is generalizable based on zoom level or not.
getLocations() Location[] Returns the locations that define the polyline.
getStrokeColor() string or Color Returns the color of the polyline.
getStrokeDashArray() string or number[] Returns the string that represents the stroke/gap sequence used to draw the polyline.
getStrokeThickness() number Returns the thickness of the polyline.
getVisible() boolean Returns whether the polyline is visible. A value of false indicates that the polyline is hidden, although it is still an entity on the map.
setLocations(locs: Location[]) Sets the locations that define the polyline.
setOptions(opt: PolylineOptions) Sets options for the polyline.

Properties

Name Type Description
metadata object Information that is linked to the polyline. Some modules such at the GeoJSON, and Spatial Data Service modules will also often add information to this property.

Events

Name Arguments Description
changed IPrimitiveChangedEventArgs Occurs when the locations or options of the polyline has changed.
click MouseEventArgs Occurs when the mouse is used to click the polyline.
dblclick MouseEventArgs Occurs when the mouse is used to double click the polyline.
mousedown MouseEventArgs Occurs when the left mouse button is pressed when the mouse is over the polyline.
mouseout MouseEventArgs Occurs when the mouse cursor moves out of the area covered by the polyline.
mouseover MouseEventArgs Occurs when the mouse is over the polyline.
mouseup MouseEventArgs Occurs when the left mouse button is lifted up when the mouse is over the polyline.