All Projects β†’ ghybs β†’ Leaflet.featuregroup.subgroup

ghybs / Leaflet.featuregroup.subgroup

Licence: bsd-2-clause
Creates a Feature Group that adds its child layers into a parent group when added to a map (e.g. through L.Control.Layers)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Leaflet.featuregroup.subgroup

Leaflet Geoman
πŸ‚πŸ—ΊοΈ The most powerful leaflet plugin for drawing and editing geometry layers
Stars: ✭ 1,088 (+1277.22%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.pixioverlay
Bring Pixi.js power to Leaflet maps
Stars: ✭ 264 (+234.18%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.MarkerCluster.LayerSupport
Sub-plugin for Leaflet.markercluster plugin; brings compatibility with Layers Control and other plugins
Stars: ✭ 53 (-32.91%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.extras2
Extra functionality for leaflet R package.
Stars: ✭ 37 (-53.16%)
Mutual labels:  leaflet-plugins, leaflet
Heatmap.js
πŸ”₯ JavaScript Library for HTML5 canvas based heatmaps
Stars: ✭ 5,685 (+7096.2%)
Mutual labels:  leaflet-plugins, leaflet
leaflet-area-select
Control to just select an area and provide bbox for it
Stars: ✭ 27 (-65.82%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet-active-area
A Leaflet plugin to center the map not in the center of the map but inside a DIV. Useful for responsive design.
Stars: ✭ 99 (+25.32%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet Panel Layers
Leaflet Control Layers extended with support groups and icons
Stars: ✭ 210 (+165.82%)
Mutual labels:  leaflet-plugins, leaflet
Iclient Javascript
Modern GIS Web Client for JavaScript, based on Leaflet\OpenLayers\MapboxGL-JS\Classic(iClient8C), enhanced with ECharts\D3\MapV etc. Contributed by SuperMap & community.
Stars: ✭ 593 (+650.63%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.markercluster
Marker Clustering plugin for Leaflet
Stars: ✭ 3,305 (+4083.54%)
Mutual labels:  leaflet-plugins, leaflet
esri-leaflet-vector
Display ArcGIS Online vector basemaps w/ Esri Leaflet
Stars: ✭ 39 (-50.63%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.markercluster.freezable
Adds ability to freeze clusters at specified zoom
Stars: ✭ 21 (-73.42%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.TileLayer.Fallback
Replaces missing Tiles by scaled lower zoom Tiles
Stars: ✭ 29 (-63.29%)
Mutual labels:  leaflet, leaflet-plugins
harp-leaflet
Leaflet plugin for harp.gl
Stars: ✭ 16 (-79.75%)
Mutual labels:  leaflet, leaflet-plugins
leaflet-defaulticon-compatibility
Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS.
Stars: ✭ 71 (-10.13%)
Mutual labels:  leaflet, leaflet-plugins
leaflet.tilelayer.gloperations
Custom Leaflet TileLayer using WebGL to do operations on and colorize floating-point pixels
Stars: ✭ 15 (-81.01%)
Mutual labels:  leaflet, leaflet-plugins
Geopackage Js
GeoPackage JavaScript Library
Stars: ✭ 191 (+141.77%)
Mutual labels:  leaflet-plugins, leaflet
Ngx Leaflet Starter
A soup of Angular and Leaflet
Stars: ✭ 208 (+163.29%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet Ant Path
🌿🐜 Creates a leaflet polyline with a 'ant-path' animated flux
Stars: ✭ 296 (+274.68%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.flowecharts
leaflet plugin for Baidu Echarts
Stars: ✭ 17 (-78.48%)
Mutual labels:  leaflet-plugins, leaflet

Leaflet.FeatureGroup.SubGroup

Creates a Leaflet Feature Group that adds its child layers into a parent group when added to a map (e.g. through L.Control.Layers).

Typical usage is to dynamically add/remove groups of markers from Marker Cluster.

Leaflet.markercluster plugin provides beautiful animated Marker Clustering functionality.

Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps.

GitHub releases npm TypeScript definitions on DefinitelyTyped types

Size: 2 kB minified, < 1 kB gzipped.

Requirements

Requires Leaflet ^1.0.0

For Leaflet ~0.7.7 use the v0.1.2 release or the leaflet-0.7 branch

Optional: Leaflet.markercluster plugin

Demos

Usage instructions

Quick Guide

HTML:

<!-- after Leaflet script -->
<script src="leaflet.featuregroup.subgroup.js"></script>

JavaScript:

var map = L.map("map"),
  parentGroup = L.markerClusterGroup(options), // Could be any other Layer Group type.
  // This is where the magic happens!
  mySubGroup = L.featureGroup.subGroup(parentGroup, arrayOfMarkers);

parentGroup.addTo(map);
mySubGroup.addTo(map);

Now adding the sub-group to the map adds clustered markers!

It should virtually be compatible with any LayerGroup plugin, not only MarkerCluster.

Installing the sub-plugin

Local copy

  1. Download the "leaflet.featuregroup.subgroup.js" file from the v1.0.2 release.
  2. Place the file alongside your page.
  3. Add the script tag (see Quick Guide > HTML) to your page after Leaflet script.

CDN

You can alternatively use the free unpkg CDN service, but keep in mind that it "is a free, best-effort service and cannot provide any uptime or support guarantees".

<!-- After Leaflet script -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.featuregroup.subgroup.js"></script>

npm

  1. Add this package to your project:

    $ npm install leaflet.featuregroup.subgroup --save
    
  2. If you are using a bundling tool, import in your JavaScript. It only performs the side effect of attaching to the global L namespace, so you do not need to store it into a local variable or import a namespace.

    require("leaflet.featuregroup.subgroup");
    // Or with ES6:
    import "leaflet.featuregroup.subgroup";
    

Creation

Simply use the L.featureGroup.subGroup factory instead of your regular L.featureGroup or L.layerGroup:

var mySubGroup = L.featureGroup.subGroup(parentGroup);

mySubGroup.addTo(map);

Do not forget to add the parent group to your map.

API Reference

Creation

Factory Description
L.featureGroup.subGroup( <ILayer> parentGroup?, <ILayer[]> layersArray? ) Creates a sub-group with events, optionally given a parent group and an initial array of child layers.

Methods

Method Returns Description
setParentGroup( <ILayer> parentGroup ) this Changes the parent group into which child markers are added to / removed from.
setParentGroupSafe( <ILayer> 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.
getParentGroup() <ILayer> Returns the current parent group.

SubGroup does not provide any extra option or event beyond what L.LayerGroup and L.FeatureGroup already provide.

Limitations

If 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.

Make sure the sub-group and its child layers are removed from map before changing the parent group, or use the setParentGroupSafe method instead.

License

license

Leaflet.FeatureGroup.SubGroup is distributed under the BSD 2-clause "Simplified" License, like Leaflet.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].