{"_id":"@bitalltech-maplibre/edit","_rev":"4-dc18fdc5d2288d2cd61720710cb6c02b","name":"@bitalltech-maplibre/edit","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@bitalltech-maplibre/edit","version":"1.0.0","keywords":["bitalltech","maplibre","edit","draw","geojson"],"license":"UNLICENSED","_id":"@bitalltech-maplibre/edit@1.0.0","maintainers":[{"name":"hanyue1218","email":"1584503074@qq.com"}],"dist":{"shasum":"512dba044b4bc9fa7bc8b2bd505589171368e5de","tarball":"https://registry.npmjs.org/@bitalltech-maplibre/edit/-/edit-1.0.0.tgz","fileCount":13,"integrity":"sha512-qsEkTNvjNyIJOZmONfYWZTSBoFUxomkk+Zxm8Ggez12aaeUzhPCnLLl07J0WLrGmfpUKFhBBKmNOnYUwLDetIQ==","signatures":[{"sig":"MEUCIQDLq9oEHuuve0a7HR6kef3LqSeWjJ1r49SrjRgGrQK5BgIgHU5qgeXYN8B+GF3zgjIb8QJPCqNHnzcUnCFvGW0+YCY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":86856},"main":"dist/index.cjs.js","style":"dist/style.css","types":"dist/types/index.d.ts","module":"dist/index.esm.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./style.css":"./dist/style.css"},"gitHead":"d8091f95b99d6cd6c94c139294005a261e682dc9","scripts":{"build":"vite build && tsc --project tsconfig.json --emitDeclarationOnly","prepublishOnly":"npm run build"},"_npmUser":{"name":"hanyue1218","email":"1584503074@qq.com"},"_npmVersion":"10.5.0","description":"BitAllTech MapLibre 编辑控件包","directories":{},"sideEffects":["*.css","src/style.css","dist/style.css"],"_nodeVersion":"20.12.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"maplibre-gl":"^5.24.0"},"_npmOperationalInternal":{"tmp":"tmp/edit_1.0.0_1783507009948_0.2813493351308147","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bitalltech-maplibre/edit","version":"1.0.2","keywords":["bitalltech","maplibre","edit","draw","geojson"],"license":"UNLICENSED","_id":"@bitalltech-maplibre/edit@1.0.2","maintainers":[{"name":"hanyue1218","email":"1584503074@qq.com"}],"dist":{"shasum":"30abed63f376042a0148b89c347a07671091be9d","tarball":"https://registry.npmjs.org/@bitalltech-maplibre/edit/-/edit-1.0.2.tgz","fileCount":14,"integrity":"sha512-ckOJKYxmQlS/1dBxfSkQkjVezeuBsKfFv+EXQqxQmVxPiRB5I/CaAxh/+lv7A2KDr9vuSg6puwkimEDXBqgQUg==","signatures":[{"sig":"MEUCIQCflVnrX0lum20OAk1yQMTdNNTy+c02Oy1za+CAgtkzDwIgLUmbo8BLWh1fEuuGrL9waQNoVk+gSAYFRgCE75EQ2YE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":115897},"main":"dist/index.cjs.js","style":"dist/style.css","types":"dist/types/index.d.ts","unpkg":"dist/index.umd.js","module":"dist/index.esm.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./style.css":"./dist/style.css"},"gitHead":"2c25cb28ec5522380181bba6304e021a6f08a9ca","scripts":{"build":"vite build && tsc --project tsconfig.json --emitDeclarationOnly","prepublishOnly":"npm run build"},"_npmUser":{"name":"hanyue1218","email":"1584503074@qq.com"},"jsdelivr":"dist/index.umd.js","_npmVersion":"10.9.8","description":"BitAllTech MapLibre 编辑控件包","directories":{},"sideEffects":["*.css","src/style.css","dist/style.css"],"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"maplibre-gl":"^5.24.0"},"_npmOperationalInternal":{"tmp":"tmp/edit_1.0.2_1786355313923_0.4308097042543808","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@bitalltech-maplibre/edit","version":"1.0.3","keywords":["bitalltech","maplibre","edit","draw","geojson"],"license":"UNLICENSED","_id":"@bitalltech-maplibre/edit@1.0.3","maintainers":[{"name":"hanyue1218","email":"1584503074@qq.com"}],"dist":{"shasum":"c08c02118cb2752b1afebb312a7f7b0f523461b1","tarball":"https://registry.npmjs.org/@bitalltech-maplibre/edit/-/edit-1.0.3.tgz","fileCount":14,"integrity":"sha512-ZyhLW78K68muHAnFvwzhy2yDy03O74L1dkij1XNZwqaMI+UAkLVDlsgCC+btCzN/AL0RRAEJsAdUpX102XNZXw==","signatures":[{"sig":"MEUCICTeUW4k1vWGoJds+Zf4Z23taFALf9RYBLd+pJJ6veuKAiEA8w38E1E3KWqImGqiVI54GRSWomlNps5XGLgKHGisKS8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":115935},"main":"dist/index.cjs.js","style":"dist/style.css","types":"dist/types/index.d.ts","unpkg":"dist/index.umd.js","module":"dist/index.esm.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./style.css":"./dist/style.css"},"gitHead":"2c25cb28ec5522380181bba6304e021a6f08a9ca","scripts":{"build":"vite build && tsc --project tsconfig.json --emitDeclarationOnly","prepublishOnly":"npm run build"},"_npmUser":{"name":"hanyue1218","email":"1584503074@qq.com"},"jsdelivr":"dist/index.umd.js","_npmVersion":"10.9.8","description":"BitAllTech MapLibre 编辑控件包","directories":{},"sideEffects":["*.css","src/style.css","dist/style.css"],"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"maplibre-gl":"^5.24.0"},"_npmOperationalInternal":{"tmp":"tmp/edit_1.0.3_1787044145580_0.3189400390767072","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@bitalltech-maplibre/edit","version":"1.0.4","description":"BitAllTech MapLibre 编辑控件包","main":"dist/index.cjs.js","module":"dist/index.esm.js","unpkg":"dist/index.umd.js","jsdelivr":"dist/index.umd.js","types":"dist/types/index.d.ts","style":"dist/style.css","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs.js"},"./style.css":"./dist/style.css"},"scripts":{"build":"vite build && tsc --project tsconfig.json --emitDeclarationOnly","prepublishOnly":"npm run build"},"keywords":["bitalltech","maplibre","edit","draw","geojson"],"license":"UNLICENSED","sideEffects":["*.css","src/style.css","dist/style.css"],"publishConfig":{"access":"public"},"peerDependencies":{"maplibre-gl":"^5.24.0"},"_id":"@bitalltech-maplibre/edit@1.0.4","gitHead":"5d62fff7e64418e5a3e3cf325e4c855352f1f36a","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-ZZbrDai7Gw6LNkHno2Hg2Qmf1Mi9fzvsVV72Nk2JjvC03L7IgLKLYRFWzoHkpcT+OiARnCNBlU7AtEQRBVjV1A==","shasum":"b74bbbcfd7c07fbb4c4c8674e4c6dce6135f4ed0","tarball":"https://registry.npmjs.org/@bitalltech-maplibre/edit/-/edit-1.0.4.tgz","fileCount":14,"unpackedSize":117232,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD3E0M3SbczqHqr/F9CGniVMryz+b5sI1ULgYzTcXfHHQIgW86zTQZqwECpv4LJBv2fjLbHiqp+rPtwtkkHC3LCacQ="}]},"_npmUser":{"name":"hanyue1218","email":"1584503074@qq.com"},"directories":{},"maintainers":[{"name":"hanyue1218","email":"1584503074@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/edit_1.0.4_1787627149056_0.4733666698467711"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-08T10:36:49.801Z","modified":"2026-08-25T03:05:49.428Z","1.0.0":"2026-07-08T10:36:50.093Z","1.0.2":"2026-08-10T09:48:34.051Z","1.0.3":"2026-08-18T09:09:05.739Z","1.0.4":"2026-08-25T03:05:49.248Z"},"license":"UNLICENSED","keywords":["bitalltech","maplibre","edit","draw","geojson"],"description":"BitAllTech MapLibre 编辑控件包","maintainers":[{"name":"hanyue1218","email":"1584503074@qq.com"}],"readme":"# @bitalltech-maplibre/edit\n\n基于 MapLibre GL JS 的轻量 GeoJSON 编辑绘制控件，支持点、线、面、矩形、圆形绘制，支持选择、拖拽移动、顶点编辑、删除，以及 GeoJSON 导入导出。\n\n## 安装\n\n```bash\nnpm install @bitalltech-maplibre/edit maplibre-gl\n```\n\n## 使用\n\n```ts\nimport \"@bitalltech-maplibre/edit/style.css\";\nimport { MaplibreEditControl } from \"@bitalltech-maplibre/edit\";\n\nconst edit = new MaplibreEditControl({\n  editable: true,\n  adsorbEnabled: true,\n  adsorbBuffer: 12,\n  styles: {\n    activeColor: \"#55b1f3\",\n    inactiveColor: \"#55b1f3\",\n    fillColor: \"#55b1f3\",\n    fillOpacity: 0.1,\n    lineWidth: 2,\n  },\n});\n\nmap.addControl(edit, \"top-left\");\n\nmap.on(\"edit.create\", (event) => {\n  console.log(event.features);\n});\n\nmap.on(\"edit.update\", (event) => {\n  console.log(event.features);\n});\n\nmap.on(\"edit.delete\", (event) => {\n  console.log(event.features);\n});\n\nconst geojson = edit.getAll();\n\nedit.setSelectedStyle({\n  activeColor: \"#f97316\",\n  inactiveColor: \"#f97316\",\n  fillColor: \"#facc15\",\n  fillOpacity: 0.25,\n  lineWidth: 4,\n});\n```\n\n## API\n\n- `setMode(mode)`：切换模式，支持 `select`、`point`、`line`、`polygon`、`rectangle`、`circle`。\n- `map.removeControl(edit)`：移除控件，并同步释放事件、图层、source 和 DOM。\n- `add(feature)`：添加一个 `Point`、`LineString` 或 `Polygon` 要素。\n- `setData(featureCollection)`：导入 GeoJSON FeatureCollection。\n- `getAll()`：导出当前全部要素。\n- `getSelected()`：获取当前选中要素。\n- `select(id)`：按 id 选中要素。\n- `delete(id?)`：删除指定或当前选中要素。\n- `clear()`：清空全部要素。\n- `setAdsorbEnabled(enabled)`：开启或关闭吸附。\n- `isAdsorbEnabled()`：获取当前吸附状态。\n- `setEditable(enabled)`：开启或关闭已完成图形的再次选择、拖拽和顶点编辑能力。\n- `isEditable()`：获取当前是否允许再次编辑。\n- `setStyles(styles)`：动态更新控件默认样式，会影响未设置独立样式的图形。\n- `setFeatureStyle(id, styles)`：设置指定图形的描边色、填充色、边框宽度、透明度等独立样式。\n- `setSelectedStyle(styles)`：设置当前选中图形的独立样式。\n\n## 图形样式\n\n单个图形的独立样式会保存在 `feature.properties.style` 中，`getAll()` 导出时会保留：\n\n```json\n{\n  \"type\": \"Feature\",\n  \"properties\": {\n    \"style\": {\n      \"inactiveColor\": \"#f97316\",\n      \"activeColor\": \"#f97316\",\n      \"fillColor\": \"#facc15\",\n      \"fillOpacity\": 0.25,\n      \"lineWidth\": 4\n    }\n  },\n  \"geometry\": {}\n}\n```\n\n## 吸附\n\n构造参数 `adsorbEnabled` 控制是否默认开启吸附，`adsorbBuffer` 控制吸附像素范围。开启后，绘制落点和顶点编辑会吸附到已有要素的顶点或线段。\n\n## 事件\n\n- `edit.create`\n- `edit.update`\n- `edit.delete`\n- `edit.selectionchange`\n- `edit.modechange`\n","readmeFilename":"README.md"}