Skip to content

Commit af91214

Browse files
stepankuzmingithub-actions[bot]
authored andcommitted
Simplify debug/pmtiles.html
GitOrigin-RevId: 8ad6f699b11f9631382d4b9e24a6be08033f1096
1 parent c9f4a8b commit af91214

1 file changed

Lines changed: 27 additions & 43 deletions

File tree

debug/pmtiles.html

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,51 @@
11
<!DOCTYPE html>
22
<html>
3-
43
<head>
54
<title>Mapbox GL JS debug page</title>
65
<meta charset="utf-8">
76
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
87
<link rel="stylesheet" href="../dist/mapbox-gl.css" />
98
<style>
10-
body {
11-
margin: 0;
12-
padding: 0;
13-
}
14-
15-
html,
16-
body,
17-
#map {
18-
height: 100%;
19-
}
9+
body { margin: 0; padding: 0; }
10+
html, body, #map { height: 100%; }
2011
</style>
2112
</head>
22-
2313
<body>
2414
<div id="map"></div>
25-
2615
<script type="module">
2716
import * as mapboxgl from '../dist/esm-dev/mapbox-gl.js';
2817
import {getAccessToken} from './access_token_generated.js';
29-
const accessToken = getAccessToken();
3018

3119
mapboxgl.addTileProvider('pmtiles', new URL('../plugins/mapbox-gl-pmtiles-provider/dist/mapbox-gl-pmtiles-provider.js', import.meta.url).href);
3220

33-
const style = await fetch(`https://api.mapbox.com/styles/v1/mapbox/standard-satellite?access_token=${accessToken}`)
34-
.then(response => response.json())
35-
.then(style => {
36-
const baseURL = new URL('../test/integration/tiles', location.href).href;
37-
style.sources = {
38-
'composite': {
39-
type: 'vector',
40-
url: baseURL + '/streets-v8-z0-z3.pmtiles'
41-
},
42-
'mapbox-dem': {
43-
type: 'raster-dem',
44-
tileSize: 256,
45-
url: baseURL + '/terrain-dem.pmtiles'
46-
},
47-
'mapbox://mapbox.satellite': {
48-
type: 'raster',
49-
tileSize: 256,
50-
url: baseURL + '/satellite-z0-z3.pmtiles'
51-
},
52-
};
53-
return style;
54-
});
55-
5621
const map = window.map = new mapboxgl.Map({
57-
accessToken: accessToken,
22+
accessToken: getAccessToken(),
5823
container: 'map',
59-
zoom: 4,
60-
center: [-112, 41],
61-
hash: true,
62-
style
24+
style: 'mapbox://styles/mapbox/standard',
25+
zoom: 1.78,
26+
center: [-103.64548, 51.14245]
27+
});
28+
29+
map.on('load', () => {
30+
map.addSource('pmtiles-earthquakes', {
31+
type: 'vector',
32+
url: 'https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.pmtiles'
33+
});
34+
35+
map.addLayer({
36+
id: 'pmtiles-vector-layer',
37+
type: 'circle',
38+
source: 'pmtiles-earthquakes',
39+
'source-layer': 'earthquakes',
40+
paint: {
41+
'circle-color': 'transparent',
42+
'circle-stroke-color': 'teal',
43+
'circle-stroke-width': 0.5,
44+
'circle-radius': 3,
45+
'circle-emissive-strength': 1
46+
}
47+
});
6348
});
6449
</script>
6550
</body>
66-
6751
</html>

0 commit comments

Comments
 (0)