Mappable JS API package
The package is located in the dist
folder:
dist/types
TypeScript typesdist/esm
es6 modules for direct connection in your projectdist/index.js
Mappable JS Module
Recommended use MMapButtonExample
as usual npm package:
npm i @mappable-world/mappable-default-ui-theme
and dynamic import
await mappable.ready;
// ...
const {MMapButtonExample} = await import('@mappable-world/mappable-default-ui-theme');
// ...
map.addChild(new MMapButtonExample(props));
You can use CDN with module loading handler in JS API on your page.
Just use mappable.import
:
const pkg = await mappable.import('@mappable-world/mappable-default-ui-theme');
By default mappable.import
can load self modules.
If you want also load your package, should add loader
:
// Add loader at start loaders array
mappable.import.loaders.unshift(async (pkg) => {
// Process only your package
if (!pkg.includes('@mappable-world/mappable-default-ui-theme')) return;
// Load script directly. You can use another CDN
await mappable.import.script(`https://unpkg.com/${pkg}/dist/index.js`);
// Return result object
return window['@mappable-world/mappable-default-ui-theme'];
});