{"id":17298198,"url":"https://github.com/wang1212/mapbox-gl-plugin-layer-group","last_synced_at":"2025-04-14T11:31:25.680Z","repository":{"id":40436714,"uuid":"267826358","full_name":"wang1212/mapbox-gl-plugin-layer-group","owner":"wang1212","description":":earth_asia: Mapbox-GL plugin, layer group management. | mapbox-GL 插件，图层组管理。","archived":false,"fork":false,"pushed_at":"2023-12-15T14:43:16.000Z","size":1032,"stargazers_count":12,"open_issues_count":32,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T00:44:06.100Z","etag":null,"topics":["layer","mapbox-gl","mapbox-gl-js","plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wang1212.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-29T10:06:26.000Z","updated_at":"2024-11-04T08:14:45.000Z","dependencies_parsed_at":"2023-12-15T15:53:48.618Z","dependency_job_id":null,"html_url":"https://github.com/wang1212/mapbox-gl-plugin-layer-group","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"wang1212/create-lib-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang1212%2Fmapbox-gl-plugin-layer-group","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang1212%2Fmapbox-gl-plugin-layer-group/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang1212%2Fmapbox-gl-plugin-layer-group/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang1212%2Fmapbox-gl-plugin-layer-group/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wang1212","download_url":"https://codeload.github.com/wang1212/mapbox-gl-plugin-layer-group/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322601,"owners_count":21084336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["layer","mapbox-gl","mapbox-gl-js","plugin"],"created_at":"2024-10-15T11:18:23.962Z","updated_at":"2025-04-14T11:31:25.610Z","avatar_url":"https://github.com/wang1212.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mapbox-GL plugin - LayerGroup\n\nThis is a plugin of [Mapbox-GL](https://docs.mapbox.com/mapbox-gl-js/overview/).\n\nThis plug-in provides the management function of [layer](https://docs.mapbox.com/mapbox-gl-js/api/#map#addlayer) groups.\n\n[Demo](./test/index.html)\n\n[English](./README.md) | [简体中文](./README.zh-CN.md)\n\n## APIs\n\nThe following APIs have been extended on [map](https://docs.mapbox.com/mapbox-gl-js/api/#map) instances:\n\n-   `addLayerGroup()`\n-   `removeLayerGroup()`\n-   `getLayerGroupFirstLayerId()`\n-   `getLayerGroupLastLayerId()`\n-   `addLayerToGroup()`\n-   `getLayerGroupLayersId()`\n-   `moveLayerGroup()`\n\nBecause the API is relatively simple and the number is very small, there is no additional API documentation provided. View the [source code](./src/index.ts) directly.\n\n## Bundle\n\nThe following bundles are provided:\n\n    types/\n    build/\n    ├── bundle.js\n    ├── bundle.min.js\n    ├── bundle.esm.js\n    ├── bundle.esm.min.js\n    ├── bundle.cjs.js\n    ├── bundle.cjs.min.js\n    ├── bundle.umd.js\n    └── bundle.umd.min.js\n\nIt also provides the corresponding **sourcemap** file.\n\n## Usage\n\n### Browser\n\nIn the browser, referenced by the `\u003cscript\u003e` tag:\n\n```html\n\u003cscript src=\"https://api.mapbox.com/mapbox-gl-js/v1.10.1/mapbox-gl.js\"\u003e\u003c/script\u003e\n\u003c!-- Reference the utils library --\u003e\n\u003cscript src=\"../build/bundle.min.js\"\u003e\u003c/script\u003e\n```\n\nThen, use it:\n\n```js\nconst map = new mapboxgl.Map({ ... })\nmap.addLayerGroup('google')\nmap.addLayerToGroup('google', /* layer{ ... } */)\n```\n\n**_If you can't get the bundle file, you can try to [build it yourself](#build)._**\n\n### Node.js\n\nInstall via npm:\n\n```bash\nnpm install mapbox-gl-plugin-layer-group\n```\n\nUse it like this:\n\n```js\n// ES Module\nimport 'mapbox-gl-plugin-layer-group'\n\n// CommonJS\nrequire('mapbox-gl-plugin-layer-group')\n```\n\n## Typescript\n\nIf you want to use [typescript](https://www.typescriptlang.org/), **@types/mapbox-gl** package type definition does not include the API provided by the plugin. However, the plugin provides expanded type definitions:\n\n```diff\n-import mapboxGL, { Map } from 'mapbox-gl'\n+import mapboxGL from 'mapbox-gl'\n+import { Map } from 'mapbox-gl-plugin-layer-group'\n\nconst map: Map = new mapboxGL.Map({ ... })\n```\n\n## Build\n\nIf you cannot get the bundle file, or you want to add additional map service resources and other reasons, you can build your own.\n\nFirst, `clone` to local\n\n```bash\ngit clone https://github.com/wang1212/mapbox-gl-plugin-layer-group.git \u003cdir\u003e\ncd \u003cdir\u003e/\nnpm install\n```\n\nThen you can modify the files in **src/** by yourself, and run the following command when finished:\n\n```bash\nnpm run build\n```\n\nThe bundle file will be generated in the **build/** folder, include **sourcemap** file.\n\n## License\n\n[MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwang1212%2Fmapbox-gl-plugin-layer-group","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwang1212%2Fmapbox-gl-plugin-layer-group","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwang1212%2Fmapbox-gl-plugin-layer-group/lists"}