Skip to content

Commit 5abfe9f

Browse files
committed
fix(geomappanel.tsx): load all fonts before rendering the map to render icons on initial load
#98
1 parent 7241136 commit 5abfe9f

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.config/webpack/webpack.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,16 @@ const config = async (env): Promise<Configuration> => ({
9898
// {
9999
// test: /fontmaki.*\.css/,
100100
// use: [
101-
// { loader: "style-loader", options: { injectType: "linkTag", attributes: { re: "preload" } } },
102-
// "css-loader"
101+
// { loader: "style-loader", options: { injectType: "linkTag", attributes: { rel: "preload", as: "style", onload: "this.rel = 'stylesheet'" } } },
102+
// // "css-loader"
103103
// ],
104104
// type: 'asset/resource',
105+
// generator: {
106+
// // Keep publicPath relative for host.com/grafana/ deployments
107+
// publicPath: `public/plugins/${pluginJson.id}/static/css/`,
108+
// outputPath: 'static/css/',
109+
// filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]',
110+
// },
105111
// },
106112
{
107113
test: /\.css$/,

src/GeomapPanel.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { isArray, isEqual } from 'lodash';
1515
import './GeomapPanel.css';
1616
import "bootstrap-icons/font/bootstrap-icons.css";
1717

18+
// Load directly when plugin
19+
import 'static/css/fontmaki2.css';
20+
import 'static/css/fontmaki.css';
21+
1822
// import 'ol-layerswitcher/dist/ol-layerswitcher.css';
1923

2024
// import WKT from 'ol/format/WKT.js';
@@ -386,6 +390,14 @@ export class GeomapPanel extends Component<Props, State> {
386390
this.map.dispose();
387391
}
388392

393+
// Load fontmaki fonts which are used for icons
394+
for (const fontFace of document.fonts) {
395+
// if (fontFace.family.toLowerCase().includes("fontmaki") ||
396+
// fontFace.family.toLowerCase().includes("grafana")) {
397+
await fontFace.load()
398+
// }
399+
}
400+
// await document.fonts.ready
389401

390402
const { options } = this.props;
391403
this.map = new Map({
@@ -513,7 +525,7 @@ export class GeomapPanel extends Component<Props, State> {
513525
}
514526
};
515527

516-
async initBasemap(cfg: ExtendMapLayerOptions) {
528+
async initBasemap(cfg: ExtendMapLayerOptions) {
517529
if (!this.map) {
518530
return;
519531
}

0 commit comments

Comments
 (0)