2018-10-09 15:00:25 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2019-02-04 20:22:02 +03:00
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<title>Martin Debug Page</title>
|
2021-04-24 20:19:37 +03:00
|
|
|
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
|
2019-02-04 20:22:02 +03:00
|
|
|
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js"></script>
|
2021-04-24 20:19:37 +03:00
|
|
|
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.css" rel="stylesheet" />
|
2019-02-04 20:22:02 +03:00
|
|
|
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#map {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div id="map"></div>
|
|
|
|
|
|
|
|
<script>
|
2019-10-26 20:37:49 +03:00
|
|
|
let accessToken = localStorage.getItem('accessToken');
|
2019-02-04 20:22:02 +03:00
|
|
|
|
2019-10-26 20:37:49 +03:00
|
|
|
if (!accessToken) {
|
|
|
|
accessToken = window.prompt('Mapbox accessToken');
|
|
|
|
localStorage.setItem('accessToken', accessToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
mapboxgl.accessToken = accessToken;
|
|
|
|
|
|
|
|
const map = new mapboxgl.Map({
|
2019-02-04 20:22:02 +03:00
|
|
|
container: 'map',
|
|
|
|
style: 'mapbox://styles/mapbox/light-v9',
|
|
|
|
zoom: 0,
|
2021-02-23 12:01:45 +03:00
|
|
|
center: [0, 0],
|
2018-10-09 15:00:25 +03:00
|
|
|
});
|
|
|
|
|
2021-04-24 20:19:37 +03:00
|
|
|
const sourceId = 'public.points1';
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2021-02-23 12:01:45 +03:00
|
|
|
map.on('load', function () {
|
2019-02-04 20:22:02 +03:00
|
|
|
map.addLayer({
|
2019-10-26 20:37:49 +03:00
|
|
|
id: sourceId,
|
2019-02-04 20:22:02 +03:00
|
|
|
type: 'circle',
|
|
|
|
source: {
|
|
|
|
type: 'vector',
|
2021-02-23 12:01:45 +03:00
|
|
|
url: `http://0.0.0.0:3000/${sourceId}.json`,
|
|
|
|
},
|
|
|
|
'source-layer': sourceId,
|
|
|
|
paint: {
|
|
|
|
'circle-color': 'red',
|
2019-02-04 20:22:02 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-02-23 12:01:45 +03:00
|
|
|
map.on('click', sourceId, function (event) {
|
2019-02-04 20:22:02 +03:00
|
|
|
console.log(event.features);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|