mapboxgl.accessToken = 'pk.eyJ1IjoibW9ob25nIiwiYSI6ImNrNGFsdjY5ZzA1NW4zbG14b2JoMnA5c3IifQ.1qVWFsyHW2wKThTgQg08SA';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-zh-v1',
center: [122.1038383,30.0234352],
zoom: 11
});
map.on('load', function() {
// map.addLayer({
// id: 'boundary',
// source: {
// type: 'vector',
// tiles: ['http://localhost:3000/v1/mvt/boundary/{z}/{x}/{y}'],
// maxzoom: 20,
// minzoom: 5
// },
// 'source-layer': 'boundary',
// type: 'fill',
// minzoom: 5,
// paint: {
// 'fill-color': 'blue'
// }
// }),
// map.addLayer({
// id: 'land',
// source: {
// type: 'vector',
// tiles: ['http://localhost:3000/v1/mvt/land/{z}/{x}/{y}'],
// maxzoom: 20,
// minzoom: 5
// },
// 'source-layer': 'land',
// type: 'fill',
// minzoom: 5,
// paint: {
// 'fill-color': 'green'
// }
// }),
// map.addLayer({
// id: 'road',
// source: {
// type: 'vector',
// tiles: ['http://localhost:3000/v1/mvt/road/{z}/{x}/{y}'],
// maxzoom: 20,
// minzoom: 5
// },
// 'source-layer': 'road',
// type: 'line',
// minzoom: 5,
// paint: {
// 'line-color': 'yellow',
// 'line-width': 10
// }
// }),
map.addLayer({
id: 'my-building',
source: {
type: 'vector',
// tiles: ['http://localhost:3000/v1/mvt/building/{z}/{x}/{y}?columns=floor'],
tiles: ['http:/localhost:3000/mvt/building/{z}/{x}/{y}'],
maxzoom: 20,
minzoom: 5
},
'source-layer': 'building',
type: 'fill-extrusion',
minzoom: 5,
paint: {
'fill-extrusion-color': 'rgb(253,174,97)',
"fill-extrusion-height": ["*", ["to-number",[ "get", "floor" ]], 3],
'fill-extrusion-opacity': 1
}
})
})
<div id='map'></div>
html,body {
padding: 0;
margin: 0;
height: 100%;
}
#map {
width: 100%;
height: 100%;
}