-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_globe.js
More file actions
37 lines (32 loc) · 1.23 KB
/
Copy pathdebug_globe.js
File metadata and controls
37 lines (32 loc) · 1.23 KB
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
// Simple test to see if mapbox works
const script = document.createElement('script');
script.src = 'https://api.mapbox.com/mapbox-gl-js/v3.16.0/mapbox-gl.js';
script.onload = () => {
const link = document.createElement('link');
link.href = 'https://api.mapbox.com/mapbox-gl-js/v3.16.0/mapbox-gl.css';
link.rel = 'stylesheet';
document.head.appendChild(link);
fetch('/api/config')
.then(r => r.json())
.then(config => {
console.log('Token received:', config.mapboxToken ? 'YES' : 'NO');
mapboxgl.accessToken = config.mapboxToken;
const container = document.createElement('div');
container.style.cssText = 'width: 400px; height: 300px; position: fixed; top: 0; left: 0; z-index: 9999; background: red;';
document.body.appendChild(container);
const map = new mapboxgl.Map({
container: container,
style: 'mapbox://styles/mapbox/dark-v11',
center: [0, 0],
zoom: 2
});
map.on('load', () => {
console.log('Mapbox loaded successfully!');
});
map.on('error', (e) => {
console.error('Mapbox error:', e);
});
})
.catch(err => console.error('API error:', err));
};
document.head.appendChild(script);