From 1caf56dc0a2bbf4bb484fe4f312b5229a63aace3 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 16 Oct 2024 16:57:47 +0800 Subject: feat: add simple script to test mapclay * add more options for generateMaps for general purposes * add rollup config for adding script into addon --- addon/index.mjs | 17 +++++++++++++++++ addon/manifest.json | 10 ++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 addon/index.mjs (limited to 'addon') diff --git a/addon/index.mjs b/addon/index.mjs new file mode 100644 index 0000000..323edf1 --- /dev/null +++ b/addon/index.mjs @@ -0,0 +1,17 @@ +const { Leaflet } = window.mapclay.renderers +const simpleRender = window.mapclay.renderWith(config => ({ + use: 'Leaflet', + width: '100%', + height: '200px', + XYZ: 'https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png', + ...config, + aliases: { + use: { Leaflet }, + ...(config.aliases ?? {}), + }, +})) + +window.generateMaps(document.querySelector('main') ?? document.body, { + initialLayout: '', + render: simpleRender, +}) diff --git a/addon/manifest.json b/addon/manifest.json index 27433b3..9cc6607 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -11,8 +11,14 @@ "content_scripts": [ { - "matches": ["*://*.mozilla.org/*"], - "js": ["index.mjs"], + "matches": [ + "*://*.mozilla.org/*", + "*://hackmd.io/*" + ], + "js": [ + "dumbymap.mjs", + "index.mjs" + ], "css": [ "css/dumbymap.css" ] -- cgit v1.2.3-70-g09d2