Reveal.js plugin to embed interactive maps in slides. DEMO
-
Copy the file
mapbox-gl.js
into the plugin folder of your reveal.js presentation, i.e.plugin/mapbox-gl
. -
Add the plugins to the dependencies in your presentation
Reveal.initialize({
// ...
dependencies: [
// ...
{ src: 'https://api.tiles.mapbox.com/mapbox-gl-js/v0.46.0/mapbox-gl.js' },
{ src: 'plugin/mapbox-gl/mapbox-gl.js'},
// ...
],
mapbox: {accessToken: "YOUR ACCESS TOKEN"}
});
- Add CSS import
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.46.0/mapbox-gl.css' rel='stylesheet' />
To add a mapbox to your presentation, simply create a container element with the
attribute data-mapbox
with the JSON configuration. The configuration can contain duration
, zoom
, bearing
and center
.
Center has to be a list [lon, lat]
.
<section data-mapbox='{"duration":4000, "zoom":13, "bearing":0, "center":[16.2957322, 50.1173050]}'>
<span class="fragment current-visible" data-mapbox-transform-to='{"duration":4000, "zoom":10, "bearing":0, "center":[36.8227, -1.2847]}'></span>
</section>
To draw path to the map you can include GeoJSON format, just add attribute data-mapbox-trek
with path to json file.
<section data-mapbox='{"duration":4000, "zoom":9, "bearing":0, "center":[37.3046, -0.1587]}'
data-mapbox-trek="data/my-expedition/mt-kenya.json">Mt.Kenya
<span class="fragment current-visible" data-mapbox-transform-to='{"duration":4000, "zoom":14, "bearing":0, "center":[37.0238, -0.1703]}'></span>
<span class="fragment current-visible" data-mapbox-transform-to='{"duration":4000, "zoom":14, "bearing":0, "center":[37.2058, 0.0538]}'></span>
</section>
MIT licensed
Copyright (C) 2018 Tomas Lipovsky