Replies: 1 comment 4 replies
-
|
Very interesting ideas. My first question would be, what do you see as the primary benefit for SSR of the map? Regardless I would be open to a PR that explores this idea, with the caveat that there remains an option for both SSR and client rendering. To me the more "elegant" solution sounds like the tile rendering option, mostly because using a headless browser seems like a large amount of overhead. I would be happy to help brainstorm more potential solutions as well when I have some time. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to present some ideas on how could SSR be handled. Do you have some other ideas or if mine has some gotchas? Are you open to accept PR?
Fix MapboxGL library to work on the server
Mentioning this just for completeness. Probably very hard.
Render just tiles
Use the tiles provider API to get image the same way like the MapboxGL does - just replace variables in the URL in LTileLayer and place that in an
<img>. Maybe more difficult if we have bounds only (I don't know how this is implemented).Maybe also add more responsive variants of the image in an srcset.
When hydratation completes
<img>will be replaced by the MapboxGL element.+ render also markers
When we have bounds coordinates of the map and markers coordinates then it could be pretty easy to calculate DOM coordinates where markers should be positioned.
Maybe not necessary, having tiles rendered is usually enough for the effect.
Headless browser to generate screenshot
Run headless browser (e.g. Puppeteer), render all pages with the map, resize to all usual screen sizes and take screenshots of the map element. Then link this screenshots in and
<img srcset=...>used as a placeholder.This is probably doable without integration with the MapboxGL as a universal Nuxt module useable with basically any client-side only component.
Will render not only tiles but basically everything the map will render.
Related: Gugustinette/nuxt-maplibre#7
Beta Was this translation helpful? Give feedback.
All reactions