Skip to content

Commit

Permalink
chore: change leaflet to lazy import
Browse files Browse the repository at this point in the history
  • Loading branch information
rockleona committed Feb 7, 2024
1 parent 24eff57 commit 70d3362
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions components/venue/VenueMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
</template>

<script>
// import { icon } from 'leaflet'
let L = { icon() {} }
if (process.browser) L = require('leaflet')
export default {
name: 'VenueMap',
data() {
Expand Down Expand Up @@ -86,21 +83,25 @@ export default {
}
},
mounted() {
this.icon = L.icon({
iconUrl: '/snake.png',
shadowUrl: '/snake-bg.png',
iconSize: [42, 42],
iconAnchor: [21, 21],
shadowSize: [45, 55],
shadowAnchor: [25, 30],
})
this.getLeaflet()
},
methods: {
centerMap() {
this.$nextTick(() => {
this.$refs.leafletMap.mapObject.panTo([25.040997, 121.611417])
})
},
async getLeaflet() {
this.L = await import('leaflet')
this.icon = this.L.icon({
iconUrl: '/snake.png',
shadowUrl: '/snake-bg.png',
iconSize: [42, 42],
iconAnchor: [21, 21],
shadowSize: [45, 55],
shadowAnchor: [25, 30],
})
},
},
}
</script>
Expand Down

0 comments on commit 70d3362

Please sign in to comment.