Skip to content

Commit

Permalink
Fixed passing correct options for markerclustergroup layer. Moved Mar…
Browse files Browse the repository at this point in the history
…kerClusterGroun out of plugin. Prepared release version.
  • Loading branch information
Igor-Vladyka committed Jul 16, 2019
1 parent 4597c4f commit 09e79fc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,28 @@ See chapter 4 of https://github.com/Asymmetrik/ngx-leaflet-tutorial-plugins/tree
### New print layers/renderers registration
To add missing print layers you need to explicitly indicate layer, it's identifier and construction function that will return actual layer object.

Example of WMS registration:
Example of L.MarkerClusterGroup registration:
``` js
L.Control.BrowserPrint.Utils.registerLayer(
L.TileLayer.WMS,
"L.TileLayer.WMS",
function(layer, utils) {
// We need to clone options to properly handle multiple renderers.
return L.tileLayer.wms(layer._url, utils.cloneOptions(layer.options));
}
);
// Actual typeof object to compare with
L.MarkerClusterGroup,
// Any string you would like for current function for print events
'L.MarkerClusterGroup',
function (layer, utils) {
// We need to recreate cluster object with available options
// Here we use function, but we can use object aswell,
// example: new L.MarkerClusterGroup(layer._group.options);
var cluster = L.markerClusterGroup(layer._group.options);

// And we clone all inner layers to our new cluster
// to properly recalculate/recreate position for print map
cluster.addLayers(utils.cloneInnerLayers(layer._group));

return cluster;
});
```

List of pre-registered layers available for printing:
* L.MarkerClusterGroup
* L.TileLayer.WMS
* L.TileLayer
* L.ImageOverlay
Expand Down
4 changes: 2 additions & 2 deletions dist/leaflet.browser.print.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/leaflet.browser.print.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ <h3 class="sub-content" leaflet-browser-print-content>Leaflet browser print plug
return L.tileLayer.wms(layer._url, layer.options);
});

L.Control.BrowserPrint.Utils.registerLayer(L.MarkerClusterGroup, 'L.MarkerClusterGroup', function (layer, utils) {
var cluster = L.markerClusterGroup(layer._group.options);
cluster.addLayers(utils.cloneInnerLayers(layer._group));
return cluster;
});

L.popup({minWidth: 500}).setLatLng(L.latLng(39.73, -104.99)).setContent("Leaflet browser print plugin with custom print Layer and content").openOn(map);

var markers = L.markerClusterGroup();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet.browser.print",
"version": "0.9.4",
"version": "1.0.0",
"keywords": [
"leaflet.js",
"browser",
Expand Down
Loading

0 comments on commit 09e79fc

Please sign in to comment.