Skip to content

Commit 09e79fc

Browse files
committed
Fixed passing correct options for markerclustergroup layer. Moved MarkerClusterGroun out of plugin. Prepared release version.
1 parent 4597c4f commit 09e79fc

File tree

6 files changed

+30
-23
lines changed

6 files changed

+30
-23
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,28 @@ See chapter 4 of https://github.com/Asymmetrik/ngx-leaflet-tutorial-plugins/tree
195195
### New print layers/renderers registration
196196
To add missing print layers you need to explicitly indicate layer, it's identifier and construction function that will return actual layer object.
197197

198-
Example of WMS registration:
198+
Example of L.MarkerClusterGroup registration:
199199
``` js
200200
L.Control.BrowserPrint.Utils.registerLayer(
201-
L.TileLayer.WMS,
202-
"L.TileLayer.WMS",
203-
function(layer, utils) {
204-
// We need to clone options to properly handle multiple renderers.
205-
return L.tileLayer.wms(layer._url, utils.cloneOptions(layer.options));
206-
}
207-
);
201+
// Actual typeof object to compare with
202+
L.MarkerClusterGroup,
203+
// Any string you would like for current function for print events
204+
'L.MarkerClusterGroup',
205+
function (layer, utils) {
206+
// We need to recreate cluster object with available options
207+
// Here we use function, but we can use object aswell,
208+
// example: new L.MarkerClusterGroup(layer._group.options);
209+
var cluster = L.markerClusterGroup(layer._group.options);
210+
211+
// And we clone all inner layers to our new cluster
212+
// to properly recalculate/recreate position for print map
213+
cluster.addLayers(utils.cloneInnerLayers(layer._group));
214+
215+
return cluster;
216+
});
208217
```
209218

210219
List of pre-registered layers available for printing:
211-
* L.MarkerClusterGroup
212220
* L.TileLayer.WMS
213221
* L.TileLayer
214222
* L.ImageOverlay

dist/leaflet.browser.print.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/leaflet.browser.print.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ <h3 class="sub-content" leaflet-browser-print-content>Leaflet browser print plug
208208
return L.tileLayer.wms(layer._url, layer.options);
209209
});
210210

211+
L.Control.BrowserPrint.Utils.registerLayer(L.MarkerClusterGroup, 'L.MarkerClusterGroup', function (layer, utils) {
212+
var cluster = L.markerClusterGroup(layer._group.options);
213+
cluster.addLayers(utils.cloneInnerLayers(layer._group));
214+
return cluster;
215+
});
216+
211217
L.popup({minWidth: 500}).setLatLng(L.latLng(39.73, -104.99)).setContent("Leaflet browser print plugin with custom print Layer and content").openOn(map);
212218

213219
var markers = L.markerClusterGroup();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "leaflet.browser.print",
3-
"version": "0.9.4",
3+
"version": "1.0.0",
44
"keywords": [
55
"leaflet.js",
66
"browser",

0 commit comments

Comments
 (0)