Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

ghybs/Leaflet.FeatureGroup.SubGroup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

Leaflet.markercluster pluginprovides beautiful animated Marker Clustering functionality.

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

GitHub releasesnpmTypeScript definitions on DefinitelyTypedtypes

Size: 2 kB minified, < 1 kB gzipped.

Requirements

Requires Leaflet ^1.0.0

For Leaflet ~0.7.7 use thev0.1.2 release or theleaflet-0.7 branch

Optional:Leaflet.markercluster plugin

Demos

Usage instructions

Quick Guide

HTML:

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

#"auto" data-snippet-clipboard-copy-content="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);">

varmap=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 thev1.0.2 release.
  2. Place the file alongside your page.
  3. Add thescript tag (seeQuick Guide > HTML) to your page after Leaflet script.

CDN

You can alternatively use the freeunpkg 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 --><scriptsrc="https://unpkg.com/leaflet.featuregroup.subgroup@1.0.2/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 globalL 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 theL.featureGroup.subGroup factory instead of your regularL.featureGroup orL.layerGroup:

varmySubGroup=L.featureGroup.subGroup(parentGroup);mySubGroup.addTo(map);

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

API Reference

Creation

FactoryDescription
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

MethodReturnsDescription
setParentGroup(<ILayer> parentGroup )thisChanges the parent group into which child markers are added to / removed from.
setParentGroupSafe(<ILayer> parentGroup )thisRemoves 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 whatL.LayerGroup andL.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 thesetParentGroupSafe method instead.

License

license

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

About

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

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp