
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
mapbox-gl-draw-freehand-mode
Advanced tools
This is a custom mode for @mapbox/mapbox-gl-draw that adds draw functionality to the draw polygon mode.
https://bemky.github.io/mapbox-gl-draw-freehand-mode/
npm i mapbox-gl-draw-freehand-mode
import FreehandMode from 'mapbox-gl-draw-freehand-mode'
const Draw = new MapboxDraw({
modes: Object.assign(MapboxDraw.modes, {
draw_polygon: FreehandMode
})
});
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [40, -74.50],
zoom: 9
});
map.addControl(Draw)
By default FreehandMode will simplify. Turf's simplify method takes a polygon and simplifies it based on a tolerance. The tolerance is corelated to meters, so tolerance must change based on the zoom, if not simplification will vary wildly based on zoom level. Thus, FreehandMode's simplify calculates a tolerance based on zoom.
You can configure you're own simplify method by redefing it on the object
import FreehandMode from 'mapbox-gl-draw-freehand-mode';
FreehandMode.simplify = function (polygon, zoom) {}
import FreehandMode from 'mapbox-gl-draw-freehand';
FreehandMode.simplify = function (polygon, zoom) {
simplify(polygon, {
mutate: true,
tolerance: 1 / Math.pow(2, zoom),
highQuality: true
});
}
Build or serve the example via Webpack
npm run build
npm run start
FAQs
a free drawing plugin for mapbox-gl-draw
The npm package mapbox-gl-draw-freehand-mode receives a total of 5,376 weekly downloads. As such, mapbox-gl-draw-freehand-mode popularity was classified as popular.
We found that mapbox-gl-draw-freehand-mode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.