Replies: 1 comment 2 replies
-
|
Hey, With the predefined vue-leaflet components (which are imported here) SSR should work as the leaflet-src will be imported only in the |
Beta Was this translation helpful? Give feedback.
2 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.
-
I would like to present some ideas on how could SSR be handled. Do you have some ideas if it has some gotchas and are you open to accept PR?
Fix Leaflet 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 Leaflet 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 Leaflet 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 Leaflet 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: #223 #4
Beta Was this translation helpful? Give feedback.
All reactions