Performance: add map.resize() at appropriate time for initial map load

This commit is contained in:
Pieter Vander Vennet 2023-12-12 13:53:49 +01:00
parent 7947fc3fbc
commit f8349cb2b9
2 changed files with 6 additions and 12 deletions

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { onDestroy, onMount } from "svelte"
import * as maplibre from "maplibre-gl"
import type { Map } from "maplibre-gl"
import * as maplibre from "maplibre-gl"
import type { Readable, Writable } from "svelte/store"
import { get, writable } from "svelte/store"
import { AvailableRasterLayers } from "../../Models/RasterLayers"
@ -44,8 +44,10 @@
interactive: true,
attributionControl: false,
})
_map.on("load", function () {
window.requestAnimationFrame(() => {
_map.resize()
})
_map.on("load", function() {
_map.resize()
})
map.set(_map)
@ -63,11 +65,6 @@
<div
bind:this={container}
class="map"
class="map relative top-0 left-0 w-full h-full"
id="map"
style=" position: relative;
top: 0;
bottom: 0;
width: 100%;
height: 100%;"
/>