forked from maputnik/osm-liberty
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
59 lines (54 loc) · 1.87 KB
/
index.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
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>OSM Liberty Topo</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.6.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.6.0/mapbox-gl.css' rel='stylesheet' />
</head>
<body>
<style>
#menu {
position: absolute;
padding: 20px;
font-family: 'Open Sans', sans-serif;
}
</style>
<div id='map'></div>
<div id="menu">
<select>
<option value="style">OSM Liberty Topo (webp)</option>
<option value="style-png" selected>OSM Liberty Topo (png)</option>
<option value="style-hybrid">OSM Liberty Hybrid (webp)</option>
<option value="style-hybrid-png">OSM Liberty Hybrid (png)</option>
<option value="style-aerial">Aerial (webp)</option>
<option value="style-aerial-png">Aerial (png)</option>
<option value="style-fstopo">USFS Topo (webp)</option>
<option value="style-fstopo-png">USFS Topo (png)</option>
</select>
</div>
<script>
var map = new mapboxgl.Map({
container: 'map',
style: 'https://raw.githubusercontent.com/nst-guide/osm-liberty-topo/gh-pages/style-png.json',
center: [-119.5936, 37.7456],
zoom: 12,
hash: true,
maxBounds: [[-130, 30], [-110, 55]]
});
map.addControl(new mapboxgl.NavigationControl());
var layerList = document.getElementById('menu');
var select = layerList.getElementsByTagName('select');
function switchLayer(layer) {
var layerId = layer.target.value;
map.setStyle('https://raw.githubusercontent.com/nst-guide/osm-liberty-topo/gh-pages/' + layerId + '.json');
}
select[0].onchange = switchLayer;
</script>
</body>
</html>