leaflet.markercluster.freezable
Advanced tools
Comparing version 0.1.1 to 1.0.0
/** | ||
* Leaflet.MarkerCluster.Freezable 0.1.1+0285b6c | ||
* Leaflet.MarkerCluster.Freezable 1.0.0+9db80a3 | ||
* Sub-plugin for Leaflet.markercluster plugin; adds the ability to freeze clusters at a specified zoom. | ||
@@ -19,3 +19,3 @@ * (c) 2015-2016 Boris Seang | ||
_originalOnAdd: L.MarkerClusterGroup.prototype.onAdd, | ||
_originalOnAddFreezable: L.MarkerClusterGroup.prototype.onAdd, | ||
@@ -25,3 +25,3 @@ onAdd: function (map) { | ||
this._originalOnAdd(map); | ||
this._originalOnAddFreezable(map); | ||
@@ -172,3 +172,6 @@ if (this._frozen) { | ||
this._topClusterLevel._recursivelyRemoveChildrenFromMap( | ||
this._currentShownBounds, previousZoom, this._getExpandedVisibleBounds() | ||
this._currentShownBounds, | ||
this._map.getMinZoom(), // New 2nd argument added in Leaflet.markercluster 1.0.4 | ||
previousZoom, | ||
this._getExpandedVisibleBounds() | ||
); | ||
@@ -222,2 +225,5 @@ this._animationZoomIn(previousZoom, targetZoom); | ||
); | ||
// Record new bounds so that newly added markers are properly displayed. | ||
this._currentShownBounds = newBounds; | ||
}, | ||
@@ -224,0 +230,0 @@ |
/*! | ||
Leaflet.MarkerCluster.Freezable 0.1.1+0285b6c | ||
Leaflet.MarkerCluster.Freezable 1.0.0+9db80a3 | ||
(c) 2015-2016 Boris Seang | ||
License MIT | ||
*/ | ||
!function(e,i){"function"==typeof define&&define.amd?define(["leaflet"],i):i("object"==typeof module&&module.exports?require("leaflet"):e.L)}(this,function(e,i){e.MarkerClusterGroup.include({_originalOnAdd:e.MarkerClusterGroup.prototype.onAdd,onAdd:function(e){var i=this._zoom;this._originalOnAdd(e),this._frozen&&(i>=0&&i!==this._zoom&&(this._featureGroup.clearLayers(),this._zoom=i,this.addLayers([])),e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),e.on("zoomend moveend",this._viewChangeEndNotClustering,this))},_originalOnRemove:e.MarkerClusterGroup.prototype.onRemove,onRemove:function(e){e.off("zoomend moveend",this._viewChangeEndNotClustering,this),this._originalOnRemove(e)},disableClustering:function(){return this.freezeAtZoom(this._maxZoom+1)},disableClusteringKeepSpiderfy:function(){return this.freezeAtZoom(this._maxZoom)},enableClustering:function(){return this.unfreeze()},unfreeze:function(){return this.freezeAtZoom(!1)},freezeAtZoom:function(e){this._processQueue();var o=this._map;e===i||e===!0||e!==e?e=o?Math.round(o.getZoom()):-1:"max"===e?e=this._maxZoom+1:"maxKeepSpiderfy"===e&&(e=this._maxZoom);var t="number"==typeof e;if(this._frozen){if(!t)return this._unfreeze(),this}else{if(!t)return this;this._initiateFreeze()}return this._artificialZoomSafe(this._zoom,e),this},_initiateFreeze:function(){var e=this._map;this._frozen=!0,e&&(e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),e.on("zoomend moveend",this._viewChangeEndNotClustering,this))},_unfreeze:function(){var e=this._map;this._frozen=!1,e&&(e.off("zoomend moveend",this._viewChangeEndNotClustering,this),e.on("zoomend",this._zoomEnd,this),e.on("moveend",this._moveEnd,this),this._executeAfterUnspiderfy(function(){this._zoomEnd()},this))},_executeAfterUnspiderfy:function(e,i){return this._unspiderfy&&this._spiderfied?(this.once("animationend",function(){e.call(i)}),void this._unspiderfy()):void e.call(i)},_artificialZoomSafe:function(e,i){this._zoom=i,this._map&&e!==i&&this._executeAfterUnspiderfy(function(){this._artificialZoom(e,i)},this)},_artificialZoom:function(e,i){e<i?(this._animationStart(),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,e,this._getExpandedVisibleBounds()),this._animationZoomIn(e,i)):e>i&&(this._animationStart(),this._animationZoomOut(e,i))},_viewChangeEndNotClustering:function(){var e=this._featureGroup,i=this._getExpandedVisibleBounds(),o=this._zoom;e.eachLayer(function(t){!i.contains(t._latlng)&&t.__parent&&t.__parent._zoom<o&&e.removeLayer(t)}),this._topClusterLevel._recursively(i,-1,o,function(t){if(t._zoom!==o)for(var n,r=t._markers,s=0;s<r.length;s++)n=t._markers[s],i.contains(n._latlng)&&e.addLayer(n)},function(e){e._addToMap()})},_originalZoomOrSpiderfy:e.MarkerClusterGroup.prototype._zoomOrSpiderfy,_zoomOrSpiderfy:function(e){this._frozen&&this.options.spiderfyOnMaxZoom?(e.layer.spiderfy(),e.originalEvent&&13===e.originalEvent.keyCode&&map._container.focus()):this._originalZoomOrSpiderfy(e)}})}); | ||
!function(e,i){"function"==typeof define&&define.amd?define(["leaflet"],i):i("object"==typeof module&&module.exports?require("leaflet"):e.L)}(this,function(e,i){e.MarkerClusterGroup.include({_originalOnAddFreezable:e.MarkerClusterGroup.prototype.onAdd,onAdd:function(e){var i=this._zoom;this._originalOnAddFreezable(e),this._frozen&&(i>=0&&i!==this._zoom&&(this._featureGroup.clearLayers(),this._zoom=i,this.addLayers([])),e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),e.on("zoomend moveend",this._viewChangeEndNotClustering,this))},_originalOnRemove:e.MarkerClusterGroup.prototype.onRemove,onRemove:function(e){e.off("zoomend moveend",this._viewChangeEndNotClustering,this),this._originalOnRemove(e)},disableClustering:function(){return this.freezeAtZoom(this._maxZoom+1)},disableClusteringKeepSpiderfy:function(){return this.freezeAtZoom(this._maxZoom)},enableClustering:function(){return this.unfreeze()},unfreeze:function(){return this.freezeAtZoom(!1)},freezeAtZoom:function(e){this._processQueue();var o=this._map;e===i||e===!0||e!==e?e=o?Math.round(o.getZoom()):-1:"max"===e?e=this._maxZoom+1:"maxKeepSpiderfy"===e&&(e=this._maxZoom);var t="number"==typeof e;if(this._frozen){if(!t)return this._unfreeze(),this}else{if(!t)return this;this._initiateFreeze()}return this._artificialZoomSafe(this._zoom,e),this},_initiateFreeze:function(){var e=this._map;this._frozen=!0,e&&(e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),e.on("zoomend moveend",this._viewChangeEndNotClustering,this))},_unfreeze:function(){var e=this._map;this._frozen=!1,e&&(e.off("zoomend moveend",this._viewChangeEndNotClustering,this),e.on("zoomend",this._zoomEnd,this),e.on("moveend",this._moveEnd,this),this._executeAfterUnspiderfy(function(){this._zoomEnd()},this))},_executeAfterUnspiderfy:function(e,i){return this._unspiderfy&&this._spiderfied?(this.once("animationend",function(){e.call(i)}),void this._unspiderfy()):void e.call(i)},_artificialZoomSafe:function(e,i){this._zoom=i,this._map&&e!==i&&this._executeAfterUnspiderfy(function(){this._artificialZoom(e,i)},this)},_artificialZoom:function(e,i){e<i?(this._animationStart(),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,this._map.getMinZoom(),e,this._getExpandedVisibleBounds()),this._animationZoomIn(e,i)):e>i&&(this._animationStart(),this._animationZoomOut(e,i))},_viewChangeEndNotClustering:function(){var e=this._featureGroup,i=this._getExpandedVisibleBounds(),o=this._zoom;e.eachLayer(function(t){!i.contains(t._latlng)&&t.__parent&&t.__parent._zoom<o&&e.removeLayer(t)}),this._topClusterLevel._recursively(i,-1,o,function(t){if(t._zoom!==o)for(var n,r=t._markers,s=0;s<r.length;s++)n=t._markers[s],i.contains(n._latlng)&&e.addLayer(n)},function(e){e._addToMap()}),this._currentShownBounds=i},_originalZoomOrSpiderfy:e.MarkerClusterGroup.prototype._zoomOrSpiderfy,_zoomOrSpiderfy:function(e){this._frozen&&this.options.spiderfyOnMaxZoom?(e.layer.spiderfy(),e.originalEvent&&13===e.originalEvent.keyCode&&map._container.focus()):this._originalZoomOrSpiderfy(e)}})}); |
{ | ||
"name": "leaflet.markercluster.freezable", | ||
"_name": "Leaflet.MarkerCluster.Freezable", | ||
"version": "0.1.1", | ||
"version": "1.0.0", | ||
"_year": "2015-2016", | ||
"description": "Sub-plugin for Leaflet.markercluster plugin; adds the ability to freeze clusters at a specified zoom.", | ||
"main": "dist/leaflet.markercluster.freezable", | ||
"files": ["dist/*.js"], | ||
"files": [ | ||
"dist/*.js" | ||
], | ||
"directories": { | ||
@@ -14,3 +16,6 @@ "example": "examples" | ||
"build": "jake build", | ||
"prepublish": "jake" | ||
"build:docs": "jake buildDocs", | ||
"version": "npm run build && npm run build:docs && git add README.md", | ||
"postversion": "npm run build", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -17,0 +22,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.MarkerCluster.Freezable | ||
@@ -17,11 +24,47 @@ Sub-plugin for [Leaflet.markercluster](https://github.com/Leaflet/Leaflet.markercluster) | ||
## Requirements | ||
This plugin should be compatible with both combinations: | ||
- Leaflet 1.0.x + Leaflet.markercluster 1.0.0 | ||
- Leaflet legacy (0.7.x) + Leaflet.markercluster legacy (0.5.x) | ||
This plugin is compatible with the following combinations: | ||
<table> | ||
<tr> | ||
<th>Leaflet</th> | ||
<th>Leaflet.markercluster</th> | ||
<th>Leaflet.MarkerCluster.Freezable</th> | ||
</tr> | ||
<tr> | ||
<td rowspan="2"> | ||
1.0.0 → 1.2.0 | ||
</td> | ||
<td> | ||
1.0.4 → 1.1.0 | ||
</td> | ||
<td> | ||
<a href="https://github.com/ghybs/Leaflet.MarkerCluster.Freezable/releases/tag/v1.0.0">1.0.0</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<!--td>("eaten" by above rowspan)</td--> | ||
<td> | ||
1.0.0 → 1.0.3 | ||
</td> | ||
<td rowspan="2"> | ||
<a href="https://github.com/ghybs/Leaflet.MarkerCluster.Freezable/releases/tag/v0.1.1">0.1.1</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
0.7.7 | ||
</td> | ||
<td> | ||
0.5.0 | ||
</td> | ||
<!--td>("eaten" by above rowspan)</td--> | ||
</tr> | ||
</table> | ||
## Demos | ||
- [Leaflet.MarkerCluster.Freezable (Leaflet 1.0.1 + Leaflet.markercluster 1.0.0)](http://ghybs.github.io/Leaflet.MarkerCluster.Freezable/examples/mcg-freezable-leaflet1.0.0.html) | ||
- [Leaflet.MarkerCluster.Freezable (Leaflet 0.7.7 + Leaflet.markercluster 0.5.0)](http://ghybs.github.io/Leaflet.MarkerCluster.Freezable/examples/mcg-freezable.html) | ||
- [Leaflet.MarkerCluster.Freezable 1.0.0 (Leaflet 1.2.0 + Leaflet.markercluster 1.1.0)](https://ghybs.github.io/Leaflet.MarkerCluster.Freezable/examples/mcg-freezable.html?leaflet=1.2.0&leaflet.markercluster=1.1.0&leaflet.markercluster.freezable=1.0.0) | ||
- [Leaflet.MarkerCluster.Freezable 0.1.1 (Leaflet 1.2.0 + Leaflet.markercluster 1.0.3)](https://ghybs.github.io/Leaflet.MarkerCluster.Freezable/examples/mcg-freezable.html?leaflet=1.2.0&leaflet.markercluster=1.0.3&leaflet.markercluster.freezable=0.1.1) | ||
- [Leaflet.MarkerCluster.Freezable 0.1.1 (Leaflet 0.7.7 + Leaflet.markercluster 0.5.0)](https://ghybs.github.io/Leaflet.MarkerCluster.Freezable/examples/mcg-freezable.html?leaflet=0.7.7&leaflet.markercluster=0.5.0&leaflet.markercluster.freezable=0.1.1) | ||
@@ -78,3 +121,3 @@ | ||
#### Local copy | ||
1. Download the "<a href="https://github.com/ghybs/Leaflet.MarkerCluster.Freezable/releases/download/v0.1.1/leaflet.markercluster.freezable.js">`leaflet.markercluster.freezable.js`</a>" file from the [`v0.1.1` release](https://github.com/ghybs/Leaflet.MarkerCluster.Freezable/releases/tag/v0.1.1). | ||
1. Download the "<a href="https://github.com/ghybs/Leaflet.MarkerCluster.Freezable/releases/download/v1.0.0/leaflet.markercluster.freezable.js">`leaflet.markercluster.freezable.js`</a>" file from the [`v1.0.0` release](https://github.com/ghybs/Leaflet.MarkerCluster.Freezable/releases/tag/v1.0.0). | ||
2. Place the file alongside your page. | ||
@@ -88,7 +131,22 @@ 3. Add the `script` tag (see [Quick Guide > HTML](#quick-guide)) to your page after Leaflet and Leaflet.markercluster scripts. | ||
<!-- After Leaflet script --> | ||
<script src="https://unpkg.com/leaflet.markercluster.freezable@0.1.1/dist/leaflet.markercluster.freezable.js"></script> | ||
<script src="https://unpkg.com/leaflet.markercluster.freezable@1.0.0/dist/leaflet.markercluster.freezable.js"></script> | ||
``` | ||
#### npm | ||
1. Add this package to your project: | ||
```bash | ||
$ npm install leaflet.markercluster.freezable --save | ||
``` | ||
2. If you are using a bundling tool, import in your JavaScript. | ||
It only performs the side effect of adding new methods to `L.markerClusterGroup`, | ||
so you do not need to store it into a local variable or import a namespace. | ||
```javascript | ||
require('leaflet.markercluster.freezable'); | ||
// Or with ES6: | ||
import 'leaflet.markercluster.freezable'; | ||
``` | ||
### Creation | ||
@@ -95,0 +153,0 @@ Simply use the the regular `L.markerClusterGroup` factory, as Freezable plugin |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
21561
6
198
1
195