我想显示带有白色背景的 Mapbox GL JS map ,而不是 map 背景。
这是我现在的代码:
mapboxgl.accessToken = 'mytoken';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v9',
minZoom: 4,
maxZoom: 14,
center: [-2.0, 53.3],
});
如何用纯白色替换浅色背景?如果我改变
style
至 white
然后我得到一个错误。
最佳答案
您不需要在 Mapbox Studio 中创建样式,您可以在浏览器中创建它:
var map = new mapboxgl.Map({
container: 'map',
style: {
version: 8,
sources: {
},
layers: [
{
id: 'background',
type: 'background',
paint: {
'background-color': 'white'
}
}
]
},
});
关于Mapbox GL JS : Set base layer to white?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42483180/