https://github.com/geoblocks/print
This project provides low level functionnalities for rendering OpenLayers layers to images of arbitrary resolution.
https://github.com/geoblocks/print
mapbox mvt openlayers print
Last synced: 3 months ago
JSON representation
This project provides low level functionnalities for rendering OpenLayers layers to images of arbitrary resolution.
- Host: GitHub
- URL: https://github.com/geoblocks/print
- Owner: geoblocks
- License: bsd-2-clause
- Created: 2021-06-29T09:34:30.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T09:05:00.000Z (about 1 year ago)
- Last Synced: 2025-06-04T01:48:27.372Z (4 months ago)
- Topics: mapbox, mvt, openlayers, print
- Language: TypeScript
- Homepage:
- Size: 3.57 MB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Geoblocks print
This project provides low level functionalities for rendering OpenLayers layers to images of arbitrary resolution.
Supported layers:
- Mapbox Vector Tiles (MVT);Supported styles:
- plain OpenLayers style functions;
- MapBox style processed by the `ol-mapbox-style` library.Supported rendering methods:
- OpenLayers render API (feature complete, default);
- OpenLayers immediate API (basic, enable with `MVTEncoder.useImmediateAPI = true`).## Demo
https://geoblocks.github.io/print

## Using
```bash
npm i @geoblocks/print
``````js
import MVTEncoder from '@geoblocks/print';
const r = await new MVTEncoder().encodeMVTLayer({
layer, // a plain OpenLayers MVT layer
tileResolution, // the resolution to use for fetching features
styleResolution, // the resolution to use for styling features
printExtent, // the extent to print
canvasSize, // the target size in dots of the rendered layer (depends of the dpi)
});
```The result is tiled so that each image is reasonably big. Each tile result contains:
- a base64 encoded image: `r[i].baseURL`;
- the OL extent for this image: `r[i].extent`.## Contributing
[contributing](./CONTRIBUTING.md)