|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <html> |
3 | | - |
4 | 3 | <head> |
5 | 4 | <title>Mapbox GL JS debug page</title> |
6 | 5 | <meta charset="utf-8"> |
7 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> |
8 | 7 | <link rel="stylesheet" href="../dist/mapbox-gl.css" /> |
9 | 8 | <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%; } |
20 | 11 | </style> |
21 | 12 | </head> |
22 | | - |
23 | 13 | <body> |
24 | 14 | <div id="map"></div> |
25 | | - |
26 | 15 | <script type="module"> |
27 | 16 | import * as mapboxgl from '../dist/esm-dev/mapbox-gl.js'; |
28 | 17 | import {getAccessToken} from './access_token_generated.js'; |
29 | | - const accessToken = getAccessToken(); |
30 | 18 |
|
31 | 19 | mapboxgl.addTileProvider('pmtiles', new URL('../plugins/mapbox-gl-pmtiles-provider/dist/mapbox-gl-pmtiles-provider.js', import.meta.url).href); |
32 | 20 |
|
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 | | - |
56 | 21 | const map = window.map = new mapboxgl.Map({ |
57 | | - accessToken: accessToken, |
| 22 | + accessToken: getAccessToken(), |
58 | 23 | 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 | + }); |
63 | 48 | }); |
64 | 49 | </script> |
65 | 50 | </body> |
66 | | - |
67 | 51 | </html> |
0 commit comments