Polygon

A newer version of Maps for web SDK is available
A newer version of the SDK is available and is recommended for all users. Learn about the latest version, V2.0, in the Maps for web v2.0 documentation

Draw a polygon on the map.

Parameters

NameDescriptiondefault
pathrequired The coordinates of the polygon, either an array or 2-D/3-D arrays/
maprequired The map instance to which the polygon attaches to/
strokeColoroptional The stroke color of the polygon'#3388ff'
strokeOpacityoptional number The opacity of the polygon, in the middle of 0-11.0
strokeWeightoptional number The stroke weight of the polygon3
fillColoroptional string The fill color of the polygon'#3388ff'
fillOpacityoptional number The fill opacity of the polygon0.2
filloptional string Whether to fill the path with colorfalse

Methods

NameDescription
enableEditTo enable editing mode to the shape.

(Not available for NextBillion.ai Maps GL)
removeTo remove the shape from the map

Example

1
var polygon = new nextbillion.maps.Polygon({
2
path: loc,
3
map: map,
4
color: 'red',
5
})
6
7
// To enable editing mode
8
// The method "enableEdit" is not available for NextBillion.ai Maps GL
9
polygon.enableEdit()
10
11
// To remove from the map
12
polygon.remove()

© 2024 NextBillion.ai all rights reserved.