Skip to content

Commit 73bfacd

Browse files
authored
Merge pull request #99 from felix-mu/98-bug-map-icon-fonts-not-loading-initially
Merge branch 98-bug-map-icon-fonts-not-loading-initially
2 parents 69f4ca8 + 1eb9bbd commit 73bfacd

File tree

6 files changed

+74
-28
lines changed

6 files changed

+74
-28
lines changed

.config/webpack/webpack.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,23 @@ const config = async (env): Promise<Configuration> => ({
9595
},
9696
},
9797
},
98+
// {
99+
// test: /fontmaki.*\.css/,
100+
// use: [
101+
// { loader: "style-loader", options: { injectType: "linkTag", attributes: { rel: "preload", as: "style", onload: "this.rel = 'stylesheet'" } } },
102+
// // "css-loader"
103+
// ],
104+
// 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+
// },
111+
// },
98112
{
99113
test: /\.css$/,
114+
// exclude: /fontmaki.*\.css/,
100115
use: ["style-loader", "css-loader"]
101116
},
102117
{

package-lock.json

Lines changed: 32 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@types/jest": "^29.5.12",
4646
"@types/lodash": "^4.14.194",
4747
"@types/node": "^18.15.11",
48-
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@^2.3.0",
48+
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@^3.6.5",
4949
"commit-and-tag-version": "^12.4.1",
5050
"commitizen": "^4.3.0",
5151
"copy-webpack-plugin": "^11.0.0",
@@ -86,7 +86,7 @@
8686
"@types/tinycolor2": "^1.4.3",
8787
"bootstrap-icons": "^1.11.2",
8888
"ol": "7.2.2",
89-
"ol-ext": "^3.2.30",
89+
"ol-ext": "^4.0.36",
9090
"ol-layerswitcher": "^4.1.2",
9191
"proj4": "^2.9.0",
9292
"react": "17.0.2",

src/GeomapPanel.tsx

Lines changed: 14 additions & 2 deletions
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({
@@ -401,7 +413,7 @@ export class GeomapPanel extends Component<Props, State> {
401413
this.mouseWheelZoom = new MouseWheelZoom();
402414
this.map.addInteraction(this.mouseWheelZoom);
403415
await this.initControls(options.controls);
404-
this.initBasemap(options.basemap);
416+
await this.initBasemap(options.basemap);
405417
await this.initLayers(options.layers);
406418
this.forceUpdate(); // first render
407419

@@ -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
}

src/editor/LayerEditor.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,15 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
228228
settings: {},
229229
defaultValue: true
230230
});
231-
builder.addBooleanSwitch({
232-
path: 'enabledForDataLinks',
233-
name: 'Toggle to include the data layer for data links',
234-
description: 'If toggled the layer is used to interpolate the data links URL.',
235-
settings: {},
236-
defaultValue: true
237-
});
231+
if (!layer.isBaseMap) {
232+
builder.addBooleanSwitch({
233+
path: 'enabledForDataLinks',
234+
name: 'Toggle to include the data layer for data links',
235+
description: 'If toggled the layer is used to interpolate the data links URL.',
236+
settings: {},
237+
defaultValue: true
238+
});
239+
}
238240
}
239241

240242
if (layer.registerOptionsUI) {
@@ -267,7 +269,7 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
267269
}
268270
};
269271

270-
const currentOptions = { ...options, type: layer.id, config: { ...layer.defaultOptions, ...options?.config } };
272+
const currentOptions = { /*...options*/...context.options, type: layer.id, config: { ...layer.defaultOptions, ...options?.config } };
271273

272274
// Update the panel options if not set
273275
if (!options || (layer.defaultOptions && !options.config)) {

src/layers/data/markersLayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export const markersLayer: ExtendMapLayerRegistryItem<MarkersConfig> = {
458458
},
459459
// Marker overlay options
460460
registerOptionsUI: (builder) => {
461-
const iconType = Object.getOwnPropertyNames(FontSymbol.prototype.defs.glyphs);
461+
const iconType = Object.getOwnPropertyNames(FontSymbol.defs.glyphs);
462462
let iconValues: any = [];
463463
iconValues.push({ value: '', label: 'none' });
464464
iconType.map((n) => iconValues.push({ value: n, label: n.replace('fa-', '') }));

0 commit comments

Comments
 (0)