Package Exports
- @polar/plugin-export
- @polar/plugin-export/src/index.ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@polar/plugin-export) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Export
Scope
The Export plugin offers users to download the currently visible map canvas in a variety of file formats and by a variety of methods.
Configuration
export
fieldName | type | description |
---|---|---|
download | boolean? | Whether file is offered for download. By default, no download will happen, and the using service is supposed to register whether a "screenshot" has been taken and react accordingly. |
showJpg | boolean? | Tools offers current map view as JPG. Defaults to true . |
showPdf | boolean? | Tools offers current map view as PDF. Defaults to true . |
showPng | boolean? | Tools offers current map view as PNG. Defaults to true . |
Example Configuration:
export: {
download: true,
showJpg: false,
showPdf: false,
showPng: true,
}
To remove user control, add displayComponent: false
to the configuration and use the following interactions.
For details on the displayComponent
attribute, refer to the Global Plugin Parameters section of @polar/core
.
Actions
To programmatically trigger a "screenshot", use this action.
// type is 'Png', 'Jpg', or 'Pdf'
map.$store.dispatch('plugin/export/exportAs', type)
State
This shows how a callback can be used to show the exported data in a suitable html element. The value of the screenshot
variable is a base64-encoded string.
const someElement = // ... however you retrieve your html element
map.subscribe('plugin/export/exportedMap', (screenshot) =>
someElement.setAttribute('src', screenshot)
)