Created
April 16, 2018 16:11
-
-
Save AlanJenkinsVS/2099ea6f1e4ba034f6d902224d05750c to your computer and use it in GitHub Desktop.
7. Rendering non-HTML - Vue JS Optimisation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const map = new mapboxgl.Map(/* ... */); | |
map.on('load', () => { | |
// Data | |
map.addSource(/* ... */); | |
// Layers | |
map.addLayer(/* ... */); | |
map.addLayer(/* ... */); | |
// Hover Effects | |
map.on('mousemove', /* ... */); | |
map.on('mouseleave', /* ... */); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MapboxMap> | |
<MapboxMapMarkers :items="cities" primary> | |
<template slot-scope="city"> | |
<h3>{{ city.name }}</h3> | |
</template> | |
</MapboxMapMarkers> | |
</MapboxNavigation/> | |
</MapboxMap> | |
<script> | |
// Abstract component | |
... | |
created () { | |
const { map } = this.$parent; | |
map.on('load', () => { | |
map.addSource(/* ... */); | |
map.addLayer(/* ... */); | |
}); | |
}, | |
beforeDestroy () { | |
const { map } = this.$parent; | |
map.on('load', () => { | |
map.removeSource(/* ... */); | |
map.removeLayer(/* ... */); | |
}); | |
}, | |
render(h) { | |
// returns nothing | |
return null; | |
} | |
... | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment