This repository has been archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mapbox.html
51 lines (48 loc) · 2.08 KB
/
mapbox.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CyclOSM - Mapbox GL JS</title>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: calc(100% - 200px); }
#legend { position: absolute; right: 10px; width: 180px; }
tr>td:first-child { text-align: center; }
td { padding: 0.5em; }
</style>
</head>
<body>
<div id='map'></div>
<div id='legend'>
<h2>CyclOSM style</h2>
<p>This is a demo of <a href="https://github.com/Phyks/cyclosm-basic-gl-style">the CyclOSM GL style</a> with tiles for <a href="https://en.wikipedia.org/wiki/%C3%8Ele-de-France">Ile-de-France</a> and using <a href="https://www.mapbox.com/mapbox-gl-js/api/">Mapbox GL JS library</a> for the render.</p>
<p>A detailed legend can be found <a href="./legend.html" target="_blank">here</a>.
</div>
<script>
fetch('../style.json').then(response => response.json()).then(
(style) => {
var mapboxToken = '{{ site.mapboxToken }}';
var maptilerToken = '{{ site.maptilerToken }}';
// Set URLS, put your access tokens below
style.sources.openmaptiles.url = 'https://api.mapbox.com/v4/phyks.bai042tw.json?secure&access_token=' + mapboxToken
style.glyphs = 'https://free.tilehosting.com/fonts/{fontstack}/{range}.pbf?key=' + maptilerToken
style.sprite = 'https://phyks.github.io/cyclosm-basic-gl-style/build/sprite'
new mapboxgl.Map({
container: 'map',
hash: true,
style: style,
center: [2.3717, 48.8340],
zoom: 10,
attributionControl: false,
}).addControl(new mapboxgl.AttributionControl({
customAttribution: '<a href="https://www.mapbox.com/about/maps/">© Mapbox</a>'
}));
}
);
</script>
</body>
</html>