{"id":22485453,"url":"https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup","last_synced_at":"2025-08-02T18:32:32.509Z","repository":{"id":39953729,"uuid":"45894415","full_name":"ghybs/Leaflet.FeatureGroup.SubGroup","owner":"ghybs","description":"Creates a Feature Group that adds its child layers into a parent group when added to a map (e.g. through L.Control.Layers)","archived":false,"fork":false,"pushed_at":"2019-08-12T17:31:43.000Z","size":104,"stargazers_count":114,"open_issues_count":0,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-24T20:08:36.437Z","etag":null,"topics":["javascript","leaflet","leaflet-plugins","markercluster","subgroups"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghybs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-10T07:12:22.000Z","updated_at":"2024-11-19T07:19:32.000Z","dependencies_parsed_at":"2022-09-05T16:51:45.875Z","dependency_job_id":null,"html_url":"https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghybs%2FLeaflet.FeatureGroup.SubGroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghybs%2FLeaflet.FeatureGroup.SubGroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghybs%2FLeaflet.FeatureGroup.SubGroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghybs%2FLeaflet.FeatureGroup.SubGroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghybs","download_url":"https://codeload.github.com/ghybs/Leaflet.FeatureGroup.SubGroup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228121069,"owners_count":17872712,"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":["javascript","leaflet","leaflet-plugins","markercluster","subgroups"],"created_at":"2024-12-06T17:12:38.250Z","updated_at":"2024-12-06T17:14:29.877Z","avatar_url":"https://github.com/ghybs.png","language":"JavaScript","readme":"\u003c!-- ##########################################################################\nNOTE TO CONTRIBUTOR:\nthis README is automatically generated from build/readme.template.md.\nShould you need to modify the README, please make your modifications on\nthe template file.\n########################################################################### --\u003e\n\n# Leaflet.FeatureGroup.SubGroup\n\nCreates a Leaflet Feature Group that adds its child layers into a parent group\nwhen added to a map (e.g. through L.Control.Layers).\n\n**Typical usage is to dynamically add/remove groups of markers from\n[Marker Cluster](https://github.com/Leaflet/Leaflet.markercluster).**\n\n[Leaflet.markercluster](https://github.com/Leaflet/Leaflet.markercluster) plugin\nprovides beautiful animated Marker Clustering functionality.\n\n[Leaflet](http://leafletjs.com/) is the leading open-source JavaScript library\nfor mobile-friendly interactive maps.\n\n[![GitHub releases](https://img.shields.io/github/release/ghybs/leaflet.featuregroup.subgroup.svg?label=GitHub)](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases)\n[![npm](https://img.shields.io/npm/v/leaflet.featuregroup.subgroup.svg)](https://www.npmjs.com/package/leaflet.featuregroup.subgroup)\n[![TypeScript definitions on DefinitelyTyped](https://definitelytyped.org/badges/standard.svg)](https://definitelytyped.org)\n[![types](https://img.shields.io/npm/types/@types/leaflet.featuregroup.subgroup)](https://www.npmjs.com/package/@types/leaflet.featuregroup.subgroup)\n\nSize: 2 kB minified, \u003c 1 kB gzipped.\n\n## Requirements\n\n_Requires Leaflet ^1.0.0_\n\n_For Leaflet ~0.7.7 use the [v0.1.2 release](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/tag/v0.1.2) or the [leaflet-0.7 branch](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/tree/leaflet-0.7)_\n\n_Optional: [Leaflet.markercluster](https://github.com/Leaflet/Leaflet.markercluster) plugin_\n\n## Demos\n\n- [SubGroup with standard L.Control.Layers and MarkerCluster](https://ghybs.github.io/Leaflet.FeatureGroup.SubGroup/examples/subGroup-markercluster-controlLayers-realworld.388.html)\n- [SubGroup with standard L.Control.Layers to display Nested Groups](https://ghybs.github.io/Leaflet.FeatureGroup.SubGroup/examples/subGroup-controlLayers-nestedGroups.html)\n\n## Usage instructions\n\n### Quick Guide\n\n**HTML:**\n\n```html\n\u003c!-- after Leaflet script --\u003e\n\u003cscript src=\"leaflet.featuregroup.subgroup.js\"\u003e\u003c/script\u003e\n```\n\n**JavaScript:**\n\n```javascript\nvar map = L.map(\"map\"),\n  parentGroup = L.markerClusterGroup(options), // Could be any other Layer Group type.\n  // This is where the magic happens!\n  mySubGroup = L.featureGroup.subGroup(parentGroup, arrayOfMarkers);\n\nparentGroup.addTo(map);\nmySubGroup.addTo(map);\n```\n\nNow adding the sub-group to the map adds clustered markers!\n\nIt should virtually be compatible with any LayerGroup plugin, not only MarkerCluster.\n\n### Installing the sub-plugin\n\n#### Local copy\n\n1. Download the \"\u003ca href=\"https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/download/v1.0.2/leaflet.featuregroup.subgroup.js\"\u003e`leaflet.featuregroup.subgroup.js`\u003c/a\u003e\" file from the [`v1.0.2` release](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/tag/v1.0.2).\n2. Place the file alongside your page.\n3. Add the `script` tag (see [Quick Guide \u003e HTML](#quick-guide)) to your page after Leaflet script.\n\n#### CDN\n\nYou can alternatively use the free [unpkg](https://unpkg.com) CDN service, but keep in mind that it \"[_is a free, best-effort service and cannot provide any uptime or support guarantees_](https://unpkg.com/#/about)\".\n\n```html\n\u003c!-- After Leaflet script --\u003e\n\u003cscript src=\"https://unpkg.com/leaflet.featuregroup.subgroup@1.0.2/dist/leaflet.featuregroup.subgroup.js\"\u003e\u003c/script\u003e\n```\n\n#### npm\n\n1. Add this package to your project:\n\n   ```bash\n   $ npm install leaflet.featuregroup.subgroup --save\n   ```\n\n2. If you are using a bundling tool, import in your JavaScript.\n   It only performs the side effect of attaching to the global `L` namespace,\n   so you do not need to store it into a local variable or import a namespace.\n   ```javascript\n   require(\"leaflet.featuregroup.subgroup\");\n   // Or with ES6:\n   import \"leaflet.featuregroup.subgroup\";\n   ```\n\n### Creation\n\nSimply use the `L.featureGroup.subGroup` factory instead of your regular `L.featureGroup` or `L.layerGroup`:\n\n```javascript\nvar mySubGroup = L.featureGroup.subGroup(parentGroup);\n\nmySubGroup.addTo(map);\n```\n\nDo not forget to add the parent group to your map.\n\n## API Reference\n\n### Creation\n\n| Factory                                                                           | Description                                                                                            |\n| :-------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |\n| **L.featureGroup.subGroup**( `\u003cILayer\u003e` parentGroup?, `\u003cILayer[]\u003e` layersArray? ) | Creates a sub-group with events, optionally given a parent group and an initial array of child layers. |\n\n### Methods\n\n| Method                                           | Returns    | Description                                                                                                                      |\n| :----------------------------------------------- | :--------- | :------------------------------------------------------------------------------------------------------------------------------- |\n| **setParentGroup**( `\u003cILayer\u003e` parentGroup )     | `this`     | Changes the parent group into which child markers are added to / removed from.                                                   |\n| **setParentGroupSafe**( `\u003cILayer\u003e` parentGroup ) | `this`     | Removes the current sub-group from map before changing the parent group. Re-adds the sub-group to map if it was before changing. |\n| **getParentGroup**()                             | `\u003cILayer\u003e` | Returns the current parent group.                                                                                                |\n\nSubGroup does not provide any extra option or event beyond what\n[L.LayerGroup](http://leafletjs.com/reference.html#layergroup) and\n[L.FeatureGroup](http://leafletjs.com/reference.html#featuregroup) already provide.\n\n## Limitations\n\nIf you change the parent group while the sub-group and/or its child markers are still on map, unexpected behaviour of the previous and/or new parent groups can happen.\n\nMake sure the sub-group and its child layers are removed from map before changing the parent group, or use the `setParentGroupSafe` method instead.\n\n## License\n\n[![license](https://img.shields.io/github/license/ghybs/leaflet.featuregroup.subgroup.svg)](LICENSE)\n\nLeaflet.FeatureGroup.SubGroup is distributed under the [BSD 2-clause \"Simplified\" License](http://choosealicense.com/licenses/bsd-2-clause/), like Leaflet.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghybs%2FLeaflet.FeatureGroup.SubGroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghybs%2FLeaflet.FeatureGroup.SubGroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghybs%2FLeaflet.FeatureGroup.SubGroup/lists"}