-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SSR (Reopen #9317) #9385
Conversation
I'll look into that asap ! |
Just tested the branch in Nuxt Leaflet playground, and it works like a charm ! Here is the example code (some Vue code) : <template>
<div style="height:100vh; width:100vw">
<h1>Basic Map Exemple</h1>
<LMap
ref="map"
:zoom="6"
:max-zoom="18"
:center="[47.21322, -1.559482]"
:use-global-leaflet="false"
@ready="onMapReady"
>
<LTileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="&copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors"
layer-type="base"
name="OpenStreetMap"
/>
</LMap>
</div>
</template>
<script setup lang="ts">
import L from 'leaflet'
import { ref } from 'vue'
const map = ref(null)
// When the map is ready
const onMapReady = () => {
console.log('Map is ready')
console.log(L)
console.log(map.value.maxZoom)
}
</script> Before, an error was thrown as SSR environment will typically load (and optimize) imports on the server-side : After, the same code now works correctly : Leaflet instance can now be loaded in a node server context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small optional comments, but this is good to merge AFAIK
Hi, when should we expect this to be released? |
I accidentally closed the other PR #9317 ... Look for more details into it
I added the changes from @jonkoops and made it work with Deno.
@Gugustinette can you please test this version?