JavaScript
var map = new mapboxgl.Map({
container: 'map',
style: 'https://maputnik.github.io/osm-liberty/style.json',
center: [79.30961608886719, 61.57192958204744],
zoom: 10,
hash: true
});
var Draw = new MapboxDraw({
userProperties: true,
styles: [{
'id': 'gl-draw-polygon-fill-inactive',
'type': 'fill',
'filter': ['all', ['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
],
'paint': {
'fill-color': [
"case", ['==', ['get', "user_class_id"], 1], "#00ff00", ['==', ['get', "user_class_id"], 2], "#0000ff",
'#ff0000'
],
'fill-outline-color': '#3bb2d0',
'fill-opacity': 0.5
}
},
{
'id': 'gl-draw-polygon-fill-active',
'type': 'fill',
'filter': ['all', ['==', 'active', 'true'],
['==', '$type', 'Polygon']
],
'paint': {
'fill-color': '#fbb03b',
'fill-outline-color': '#fbb03b',
'fill-opacity': 0.1
}
},
{
'id': 'gl-draw-polygon-midpoint',
'type': 'circle',
'filter': ['all', ['==', '$type', 'Point'],
['==', 'meta', 'midpoint']
],
'paint': {
'circle-radius': 3,
'circle-color': '#fbb03b'
}
},
{
'id': 'gl-draw-polygon-stroke-inactive',
'type': 'line',
'filter': ['all', ['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
],
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-color': '#3bb2d0',
'line-width': 2
}
},
{
'id': 'gl-draw-polygon-stroke-active',
'type': 'line',
'filter': ['all', ['==', 'active', 'true'],
['==', '$type', 'Polygon']
],
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-color': '#fbb03b',
'line-dasharray': [0.2, 2],
...