{"_id":"@abi-software/mapbox-gl-draw-freehand-mode","_rev":"3-46288f8aac9aa2b272ba78468fdf10c0","name":"@abi-software/mapbox-gl-draw-freehand-mode","dist-tags":{"latest":"2.2.0"},"versions":{"2.2.0":{"name":"@abi-software/mapbox-gl-draw-freehand-mode","version":"2.2.0","keywords":["mapbox","mapbox-gl","mapbox-gl-draw","geojson"],"author":{"name":"Ben Ehmke"},"license":"ISC","_id":"@abi-software/mapbox-gl-draw-freehand-mode@2.2.0","maintainers":[{"name":"ddjnw1yu","email":"david.jianwei.yu@outlook.com"},{"name":"hsorby","email":"h.sorby@auckland.ac.nz"},{"name":"alan-wu","email":"alan.wu@auckland.ac.nz"},{"name":"tehsurfer","email":"jessekhorasanee@gmail.com"},{"name":"agarny","email":"agarny@hellix.com"},{"name":"dbrnz","email":"d.brooks@auckland.ac.nz"}],"homepage":"https://github.com/bemky/mapbox-gl-draw-free-mode#readme","bugs":{"url":"https://github.com/bemky/mapbox-gl-draw-free-mode/issues"},"dist":{"shasum":"1c0de794ce2d6ea2a229a497182b3d0921939097","tarball":"https://registry.npmjs.org/@abi-software/mapbox-gl-draw-freehand-mode/-/mapbox-gl-draw-freehand-mode-2.2.0.tgz","fileCount":9,"integrity":"sha512-2iP44byEs0nGxUaGzCio1qeZBR3tLK+xUMAMTpWykaDNeVFgVjIb57RW5l6hJMrtTD0zNNkQV9CgGgaPJVYMRQ==","signatures":[{"sig":"MEQCIHf+lyGeOyGMD87FgrSRVOBnzmnVC+ghIXEAx/RltDc7AiBK1224TPFUocY/q7y7oNUvvPIY0yy+k4F+cCbXBgLbpA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":193412},"main":"src/index.js","gitHead":"4edd6fda27c3447136c134fc025281a1430808b9","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"webpack --mode=production","start":"npx webpack serve --mode=development"},"_npmUser":{"name":"dbrnz","email":"d.brooks@auckland.ac.nz"},"repository":{"url":"git+https://github.com/AnatomicMaps/mapbox-gl-draw-free-mode.git","type":"git"},"_npmVersion":"10.2.3","description":"a free drawing plugin for mapbox-gl-draw","directories":{},"_nodeVersion":"18.19.0","dependencies":{"@turf/simplify":"^6.3.0","@mapbox/mapbox-gl-draw":"^1.4.3"},"_hasShrinkwrap":false,"devDependencies":{"webpack":"^5.38.1","webpack-cli":"^4.7.2","webpack-dev-server":"^3.11.2"},"_npmOperationalInternal":{"tmp":"tmp/mapbox-gl-draw-freehand-mode_2.2.0_1707267358861_0.8995399192580691","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-02-07T00:55:58.728Z","modified":"2026-04-01T09:49:27.571Z","2.2.0":"2024-02-07T00:55:59.069Z"},"bugs":{"url":"https://github.com/bemky/mapbox-gl-draw-free-mode/issues"},"author":{"name":"Ben Ehmke"},"license":"ISC","homepage":"https://github.com/bemky/mapbox-gl-draw-free-mode#readme","keywords":["mapbox","mapbox-gl","mapbox-gl-draw","geojson"],"repository":{"url":"git+https://github.com/AnatomicMaps/mapbox-gl-draw-free-mode.git","type":"git"},"description":"a free drawing plugin for mapbox-gl-draw","maintainers":[{"email":"h.sorby@auckland.ac.nz","name":"hsorby"},{"email":"alan.wu@auckland.ac.nz","name":"alan-wu"},{"email":"agarny@hellix.com","name":"agarny"},{"email":"d.brooks@auckland.ac.nz","name":"dbrnz"},{"email":"aung.kyaw.hein@auckland.ac.nz","name":"akhuoa"}],"readme":"# Mapbox Free Draw Mode\n\nThis is a custom mode for [@mapbox/mapbox-gl-draw]() that adds draw functionality to the draw polygon mode.\n\n## Demo\nhttps://bemky.github.io/mapbox-gl-draw-freehand-mode/\n\n## Dependencies\n[@mapbox/mapbox-gl-draw](https://www.npmjs.com/package/mapbox-gl-draw)\n\n[@turf/simplify](https://www.npmjs.com/package/@turf/simplify)\n\n## Usage\n### To Install:\n    npm i mapbox-gl-draw-freehand-mode\n\n### To Use:\n```javascript\nimport FreehandMode from 'mapbox-gl-draw-freehand-mode'\n\nconst Draw = new MapboxDraw({\n  modes: Object.assign(MapboxDraw.modes, {\n    draw_polygon: FreehandMode\n  })\n});\n\nvar map = new mapboxgl.Map({\n  container: 'map',\n  style: 'mapbox://styles/mapbox/streets-v8',\n  center: [40, -74.50],\n  zoom: 9\n});\nmap.addControl(Draw)\n```\n\n## Configuration\n### Simplification\nBy default FreehandMode will simplify. Turf's [simplify](https://www.npmjs.com/package/@turf/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.\n\nYou can configure you're own simplify method by redefing it on the object\n\n#### Example removing simplification\n```javascript\nimport FreehandMode from 'mapbox-gl-draw-freehand-mode';\n\nFreehandMode.simplify = function (polygon, zoom) {}\n```\n\n#### Example with your own tolerance calculation\n```javascript\nimport FreehandMode from 'mapbox-gl-draw-freehand';\n\nFreehandMode.simplify = function (polygon, zoom) {\n    simplify(polygon, {\n        mutate: true,\n        tolerance: 1 / Math.pow(2, zoom),\n        highQuality: true\n    });\n}\n```\n\n## Development\nBuild or serve the example via [Webpack](https://webpack.js.org/)\n\n### Build\n    npm run build\n\n### Serve\n    npm run start\n","readmeFilename":"README.md"}