
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
@camptocamp/inkmap
Advanced tools
A library for generating printable, high quality maps in the browser.
inkmap is based on OpenLayers and will generate maps in PNG format based on a given JSON specification.
inkmap can handle long-running jobs (e.g. A0 format in 300 dpi) and provides an API for following a job progress. It uses a service worker in the background provided the user browser supports OffscreenCanvas, and falls back (almost) seamlessly to the main thread if not.
Please note that the first version of inkmap has been entirely funded and supported by the French Ministry of Ecology as part of their Descartes web mapping toolkit, hosted here: https://adullact.net/projects/descartes/
To include the library in your project:
$ npm install --save @camptocamp/inkmap
Then import the different methods from the inkmap
package:
import { print, downloadBlob } from '@camptocamp/inkmap';
print({
layers: [ ... ],
projection: 'EPSG:4326',
...
}).then(downloadBlob);
inkmap offers advanced job monitoring through the use of Observables provided by the rxjs library.
Observables are different from Promises in that they can emit multiple values instead of just one, and are a very good fit for progress reporting.
To use an Observable, simply call its subscribe()
method with a function as argument. The function will be called anytime a new value is emitted, like so:
import { getJobStatus } from '@camptocamp/inkmap';
...
getJobStatus(jobId).subscribe((jobStatus) => {
// do something with the status
});
Note that for long-lived Observables (i.e. Observables that never completes) it is important to call unsubscribe()
when the emitted values are not needed anymore. Open subscriptions to Observables might create memory leaks.
inkmap can and will use a dedicated service worker for running print jobs if given the chance. This offers the following advantages:
To enable this, the inkmap-worker.js
file located in the dist
folder must be published on the same path as the application
using inkmap.
The worker file can be published either using a symbolic link or by actually copying the file, for example in the application build pipeline.
If using Webpack to build the application, a solution is to use the CopyWebpackPlugin:
export default {
...
plugins: [
new CopyWebpackPlugin([
{
from: 'node_modules/@camptocamp/inkmap/dist/inkmap-worker.js',
to: 'dist'
},
]),
],
...
}
Important note: all API functions are named exports from the inkmap
package.
See the API documentation website.
Under the hood, inkmap
will attempt to install a service worker on the page it is called. The service worker will then be in charge
of loading all the map images and data, composing them together and giving them back to the application code.
See CONTRIBUTING.
FAQs
A library for generating printable, high quality maps in the browser.
We found that @camptocamp/inkmap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.