dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
283 stars 34 forks source link

Resize issue #85

Closed wx007 closed 8 months ago

wx007 commented 8 months ago

Anyone know how to programmatically call the maplibre resize() method from svelte-maplibre? I'm having an issue where maps don't stretch to fill their parent container when they are loaded. Using vanilla Javascript I get get the map to expand by issuing map.resize() immediately after load. Through various tests and googling it appears that the canvas is not picking up the parent container's size when it loads. Regardless, need to resize the map as the window is resized so it would be nice to have access to this method through the svelte component. Any ideas?

Thanks!

wx007 commented 8 months ago

Figured it out. Apparently, you need to explicitly set the parent container width and height. The parent container's implicit size is not picked up by maplibre for some reason. I set sizes to 100% and now the map elements correctly stretch to fill their parent divs.