leaflet.featuregroup.subgroup
Advanced tools
Comparing version 1.0.1 to 1.0.2
# Leaflet.FeatureGroup.SubGroup Changelog | ||
## 1.0.1 (2016-04-22) for Leaflet 1.0 | ||
## 1.0.2 (2017-03-26) for Leaflet 1.0+ | ||
- Fixed `removeLayer` when parent is a MarkerClusterGroup (by [@darthsteven](https://github.com/darthsteven)) [#12](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/pull/12) | ||
## 1.0.1 (2016-09-23) for Leaflet 1.0 | ||
- Fixed UMD wrapper, now side effect only [#8](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/issues/8) | ||
@@ -7,0 +12,0 @@ |
/** | ||
* Leaflet.FeatureGroup.SubGroup 1.0.1+acb1fa6 | ||
* Leaflet.FeatureGroup.SubGroup 1.0.2+00bb0d4 | ||
* Creates a Leaflet Feature Group that adds its child layers into a parent group when added to a map | ||
* (c) 2015-2016 Boris Seang | ||
* (c) 2015-2017 Boris Seang | ||
* License BSD-2-Clause | ||
@@ -164,16 +164,19 @@ */ | ||
_removeLayerFromGroup: function (layer) { | ||
// If unknown layer, skip. | ||
if (!this.hasLayer(layer)) { | ||
return this; | ||
} | ||
if (layer in this._layers) { | ||
layer = this._layers[layer]; | ||
} | ||
layer.removeEventParent(this); | ||
// Retrieve the layer id. | ||
var id = layer in this._layers ? layer : this.getLayerId(layer); | ||
if (this._map && this._layers[id]) { | ||
// Retrieve the layer from this._layer. | ||
layer = this._layers[id]; | ||
// Unregister from events parent. | ||
layer.removeEventParent(this); | ||
if (this._map && layer) { | ||
// Remove from parent group instead of directly from map. | ||
this._parentGroup.removeLayer(id); | ||
this._parentGroup.removeLayer(layer); | ||
} | ||
@@ -204,2 +207,2 @@ | ||
//# sourceMappingURL=leaflet.featuregroup.subgroup-src.map | ||
//# sourceMappingURL=leaflet.featuregroup.subgroup-src.js.map |
/*! | ||
Leaflet.FeatureGroup.SubGroup 1.0.1+acb1fa6 | ||
(c) 2015-2016 Boris Seang | ||
Leaflet.FeatureGroup.SubGroup 1.0.2+00bb0d4 | ||
(c) 2015-2017 Boris Seang | ||
License BSD-2-Clause | ||
*/ | ||
!function(e,r){"function"==typeof define&&define.amd?define(["leaflet"],r):r("object"==typeof module&&module.exports?require("leaflet"):e.L)}(this,function(e){e.FeatureGroup.SubGroup=e.FeatureGroup.extend({initialize:function(r,t){e.FeatureGroup.prototype.initialize.call(this,t),this.setParentGroup(r)},setParentGroup:function(r){var t=r instanceof e.LayerGroup;return this._parentGroup=r,this.onAdd=t?"function"==typeof r.addLayers?this._onAddToGroupBatch:this._onAddToGroup:this._onAddToMap,this.onRemove=t?"function"==typeof r.removeLayers?this._onRemoveFromGroupBatch:this._onRemoveFromGroup:this._onRemoveFromMap,this.addLayer=t?this._addLayerToGroup:this._addLayerToMap,this.removeLayer=t?this._removeLayerFromGroup:this._removeLayerFromMap,this},setParentGroupSafe:function(e){var r=this._map;return r&&r.removeLayer(this),this.setParentGroup(e),r&&r.addLayer(this),this},getParentGroup:function(){return this._parentGroup},_onAddToGroupBatch:function(e){var r=this.getLayers();this._map=e,this._parentGroup.addLayers(r)},_onRemoveFromGroupBatch:function(){var e=this.getLayers();this._parentGroup.removeLayers(e),this._map=null},_onAddToGroup:function(e){var r=this._parentGroup;this._map=e,this.eachLayer(r.addLayer,r)},_onRemoveFromGroup:function(){var e=this._parentGroup;this.eachLayer(e.removeLayer,e),this._map=null},_onAddToMap:e.FeatureGroup.prototype.onAdd,_onRemoveFromMap:e.FeatureGroup.prototype.onRemove,_addLayerToGroup:function(e){if(this.hasLayer(e))return this;e.addEventParent(this);var r=this.getLayerId(e);return this._layers[r]=e,this._map&&this._parentGroup.addLayer(e),this.fire("layeradd",{layer:e})},_removeLayerFromGroup:function(e){if(!this.hasLayer(e))return this;e in this._layers&&(e=this._layers[e]),e.removeEventParent(this);var r=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[r]&&this._parentGroup.removeLayer(r),delete this._layers[r],this.fire("layerremove",{layer:e})},_addLayerToMap:e.FeatureGroup.prototype.addLayer,_removeLayerFromMap:e.FeatureGroup.prototype.removeLayer}),e.featureGroup.subGroup=function(r,t){return new e.FeatureGroup.SubGroup(r,t)}}); | ||
!function(e,r){"function"==typeof define&&define.amd?define(["leaflet"],r):r("object"==typeof module&&module.exports?require("leaflet"):e.L)}(this,function(e){e.FeatureGroup.SubGroup=e.FeatureGroup.extend({initialize:function(r,t){e.FeatureGroup.prototype.initialize.call(this,t),this.setParentGroup(r)},setParentGroup:function(r){var t=r instanceof e.LayerGroup;return this._parentGroup=r,this.onAdd=t?"function"==typeof r.addLayers?this._onAddToGroupBatch:this._onAddToGroup:this._onAddToMap,this.onRemove=t?"function"==typeof r.removeLayers?this._onRemoveFromGroupBatch:this._onRemoveFromGroup:this._onRemoveFromMap,this.addLayer=t?this._addLayerToGroup:this._addLayerToMap,this.removeLayer=t?this._removeLayerFromGroup:this._removeLayerFromMap,this},setParentGroupSafe:function(e){var r=this._map;return r&&r.removeLayer(this),this.setParentGroup(e),r&&r.addLayer(this),this},getParentGroup:function(){return this._parentGroup},_onAddToGroupBatch:function(e){var r=this.getLayers();this._map=e,this._parentGroup.addLayers(r)},_onRemoveFromGroupBatch:function(){var e=this.getLayers();this._parentGroup.removeLayers(e),this._map=null},_onAddToGroup:function(e){var r=this._parentGroup;this._map=e,this.eachLayer(r.addLayer,r)},_onRemoveFromGroup:function(){var e=this._parentGroup;this.eachLayer(e.removeLayer,e),this._map=null},_onAddToMap:e.FeatureGroup.prototype.onAdd,_onRemoveFromMap:e.FeatureGroup.prototype.onRemove,_addLayerToGroup:function(e){if(this.hasLayer(e))return this;e.addEventParent(this);var r=this.getLayerId(e);return this._layers[r]=e,this._map&&this._parentGroup.addLayer(e),this.fire("layeradd",{layer:e})},_removeLayerFromGroup:function(e){if(!this.hasLayer(e))return this;var r=e in this._layers?e:this.getLayerId(e);return e=this._layers[r],e.removeEventParent(this),this._map&&e&&this._parentGroup.removeLayer(e),delete this._layers[r],this.fire("layerremove",{layer:e})},_addLayerToMap:e.FeatureGroup.prototype.addLayer,_removeLayerFromMap:e.FeatureGroup.prototype.removeLayer}),e.featureGroup.subGroup=function(r,t){return new e.FeatureGroup.SubGroup(r,t)}}); |
{ | ||
"name": "leaflet.featuregroup.subgroup", | ||
"_name": "Leaflet.FeatureGroup.SubGroup", | ||
"version": "1.0.1", | ||
"_year": "2015-2016", | ||
"version": "1.0.2", | ||
"_year": "2015-2017", | ||
"description": "Creates a Leaflet Feature Group that adds its child layers into a parent group when added to a map", | ||
"main": "dist/leaflet.featuregroup.subgroup.js", | ||
"files": ["dist/"], | ||
"main": "dist/leaflet.featuregroup.subgroup", | ||
"files": [ | ||
"dist/*.js" | ||
], | ||
"directories": { | ||
@@ -14,3 +16,5 @@ "example": "examples" | ||
"build": "jake build", | ||
"prepublish": "jake" | ||
"version": "npm run build && jake buildDocs && git add README.md", | ||
"postversion": "npm run build", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -17,0 +21,0 @@ "repository": { |
@@ -0,1 +1,8 @@ | ||
<!-- ########################################################################## | ||
NOTE TO CONTRIBUTOR: | ||
this README is automatically generated from build/readme.template.md. | ||
Should you need to modify the README, please make your modifications on | ||
the template file. | ||
########################################################################### --> | ||
# Leaflet.FeatureGroup.SubGroup | ||
@@ -14,3 +21,4 @@ Creates a Leaflet Feature Group that adds its child layers into a parent group | ||
Latest SubGroup release: [v1.0.1](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/tag/v1.0.1) | ||
[](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases) | ||
[](https://www.npmjs.com/package/leaflet.featuregroup.subgroup) | ||
@@ -22,3 +30,3 @@ Size: 2 kB minified, < 1 kB gzipped. | ||
## Requirements | ||
*Requires Leaflet 1.0.0-rc.1* | ||
*Requires Leaflet 1.0.0* | ||
@@ -32,4 +40,4 @@ *For Leaflet 0.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)* | ||
## Demos | ||
- [SubGroup with standard L.Control.Layers and MarkerCluster](http://ghybs.github.io/Leaflet.FeatureGroup.SubGroup/examples/subGroup-markercluster-controlLayers-realworld.388.html) | ||
- [SubGroup with standard L.Control.Layers to display Nested Groups](http://ghybs.github.io/Leaflet.FeatureGroup.SubGroup/examples/subGroup-controlLayers-nestedGroups.html) | ||
- [SubGroup with standard L.Control.Layers and MarkerCluster](https://ghybs.github.io/Leaflet.FeatureGroup.SubGroup/examples/subGroup-markercluster-controlLayers-realworld.388.html) | ||
- [SubGroup with standard L.Control.Layers to display Nested Groups](https://ghybs.github.io/Leaflet.FeatureGroup.SubGroup/examples/subGroup-controlLayers-nestedGroups.html) | ||
@@ -67,3 +75,3 @@ | ||
#### Local copy | ||
1. Download the "<a href="https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/download/v1.0.1/leaflet.featuregroup.subgroup.js">`leaflet.featuregroup.subgroup.js`</a>" file from the [`v1.0.1` release](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/tag/v1.0.1). | ||
1. Download the "<a href="https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/download/v1.0.2/leaflet.featuregroup.subgroup.js">`leaflet.featuregroup.subgroup.js`</a>" file from the [`v1.0.2` release](https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup/releases/tag/v1.0.2). | ||
2. Place the file alongside your page. | ||
@@ -73,7 +81,7 @@ 3. Add the `script` tag (see [Quick Guide > HTML](#quick-guide)) to your page after Leaflet script. | ||
#### CDN | ||
You 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)". | ||
You 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)". | ||
```html | ||
<!-- After Leaflet script --> | ||
<script src="https://unpkg.com/leaflet.featuregroup.subgroup@1.0.1/leaflet.featuregroup.subgroup.js"></script> | ||
<script src="https://unpkg.com/leaflet.featuregroup.subgroup@1.0.2/dist/leaflet.featuregroup.subgroup.js"></script> | ||
``` | ||
@@ -123,2 +131,4 @@ | ||
## License | ||
[](LICENSE) | ||
Leaflet.FeatureGroup.SubGroup is distributed under the [BSD 2-clause "Simplified" License](http://choosealicense.com/licenses/bsd-2-clause/), like Leaflet. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
159
129
0
16730
6