Replies: 5 comments 4 replies
-
I think using resize event isn't a good idea.
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! I have tried any number of combos with this and had the same problem with all of them. But you're quite right - in the jsbin the "idle" event is indeed working ok. I have tested the 'idle' listener in my own project again and it's still producing blank images. My theory here is similar to the difference between having the developer tools open vs not. The timing is just slightly different for the idle handler in the pastebin vs in my project which of course is drawing a lot more on the map than just this simple example. |
Beta Was this translation helpful? Give feedback.
-
You need to use preserveDrawingBuffer. |
Beta Was this translation helpful? Give feedback.
-
As far as I know, preserveDrawingBuffer was already used in this example.
|
Beta Was this translation helpful? Give feedback.
-
I seem to have a fix. In my stupidity I hadn't updated the maplibre library as my first step. I assumed that the problem existed in the current version because my jsbin test also had the issue. That however was more down to using the 'resize' event handler rather than the 'idle' handler. After updating to the latest version I am able to quite reliably export images at a high res now. I even added in an extra step to detect the user's max webgl texture size to push the size past the 4096 pixels. It's generating some very nice high resolution maps. Thanks to @HarelM and @sbachinin for taking the time to respond and provide assistance. |
Beta Was this translation helpful? Give feedback.
-
maplibre-gl-js version: latest
browser: Chrome
Steps to Trigger Behavior
map.setPixelRatio()
to a higher resolution.map.getCanvas().toDataURL()
ormap.getCanvas().toBlob()
map.resize()
Link to Demonstration
https://output.jsbin.com/tikuhuk/5
Expected Behavior
The image saves at the higher resolution.
Actual Behavior
It almost always saves a blank image in Chrome.
Opening the dev inspector while saving the image does result in the save working, which makes me think there is some kind of timing issue going on that is affected by the inspector being open
My research into this issue led me to the preserveDrawingBuffer setting which seemed like it must be somehow related. However, setting this to true in the maplibre options does not resolve the issue.
Relevant code below because jsbin is not working properly
Beta Was this translation helpful? Give feedback.
All reactions