Built with blockbuilder.org
xxxxxxxxxx
<html>
<head>
<meta charset='utf-8' />
<title>Display a map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.css' rel='stylesheet' />
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id='map'></div>
<script>
const accessToken = 'pk.eyJ1Ijoiemhhbmd6aWhhbyIsImEiOiJjamN6dDF1bzMwenphMzNuMjlqaG1vOTJlIn0.VdSfOPUC85YcWqs3LZeXmA';
// const mapStyle = 'mapbox://styles/zhangzihao/cjys2zruc07k01cphr475j46z';
const mapStyle = 'mapbox://styles/zhangzihao/cjysfjioh01q41com97agvcxl';
// access token
mapboxgl.accessToken = accessToken;
var map = new mapboxgl.Map({
container: 'map', // container id
style: mapStyle, // stylesheet location
center: [120.75404576100846, 30.756043059454512], // starting position [lng, lat]
zoom: 3. // starting zoom
});
//调试使用
map.on("click", function (e) {
console.log(e.lngLat);
});
</script>
</body>
</html>
https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.js