Redraw map canvases after Monda loads
This commit is contained in:
@@ -13,6 +13,7 @@ import { download } from '../../helpers/download'
|
|||||||
export const MapView: Component<{ type: MapResolution, data: () => ResultKeyVal[], mode?: "temperature" | "faktiska", productionTemplate?: boolean }> = ({ type, data, mode = "temperature", productionTemplate = false }) => {
|
export const MapView: Component<{ type: MapResolution, data: () => ResultKeyVal[], mode?: "temperature" | "faktiska", productionTemplate?: boolean }> = ({ type, data, mode = "temperature", productionTemplate = false }) => {
|
||||||
const [getCanvas, setCanvas] = createSignal<HTMLCanvasElement>();
|
const [getCanvas, setCanvas] = createSignal<HTMLCanvasElement>();
|
||||||
const [getImg, setImg] = createSignal(new Image());
|
const [getImg, setImg] = createSignal(new Image());
|
||||||
|
const [fontReady, setFontReady] = createSignal(false);
|
||||||
const weatherIconsSignal = createSignal<{[key: string]: string;}>({});
|
const weatherIconsSignal = createSignal<{[key: string]: string;}>({});
|
||||||
const [getWeatherIcons] = weatherIconsSignal;
|
const [getWeatherIcons] = weatherIconsSignal;
|
||||||
const [getTitle, setTitle] = createSignal("");
|
const [getTitle, setTitle] = createSignal("");
|
||||||
@@ -42,6 +43,7 @@ export const MapView: Component<{ type: MapResolution, data: () => ResultKeyVal[
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
void document.fonts.load(`700 ${props.fontSize}px Monda`).then(() => setFontReady(true));
|
||||||
const ctx = getCanvas()!.getContext("2d")!;
|
const ctx = getCanvas()!.getContext("2d")!;
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
@@ -60,6 +62,7 @@ export const MapView: Component<{ type: MapResolution, data: () => ResultKeyVal[
|
|||||||
});
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
fontReady();
|
||||||
const ctx = getCanvas()!.getContext("2d")!;
|
const ctx = getCanvas()!.getContext("2d")!;
|
||||||
const weatherIcons = getWeatherIcons();
|
const weatherIcons = getWeatherIcons();
|
||||||
const coordsAndData: CityData[] = data()
|
const coordsAndData: CityData[] = data()
|
||||||
|
|||||||
Reference in New Issue
Block a user