Fab*_*ala 5 html web-applications mapbox mapbox-gl mapbox-gl-js
我是 Mapbox 的新手,最近我想创建一个网络地图。我将一个形状上传到 mapbox tilseset cloud 中,但是当我尝试将其添加到地图中时,它不显示。这是我正在使用的代码函数:
map.on('load', function() {
map.addLayer({
'id' : 'Resguardos',
'type' : 'fill',
"source" : {
'type' : 'vector',
'url' : 'mapbox://fabiofz1990.9lhgml6c',
},
'layout' : {},
'paint' : {
'fill-color' : '#0044b2',
'fill-opacity' : 1
}
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢
您可以直接从 Mapbox studio 添加图块集。
map.addSource('tileset_data', {
"url": "mapbox://abcqqq123.cklxcyxew1b9421lpb8shxf4x-2ikvs",
"type": "vector"
});
Run Code Online (Sandbox Code Playgroud)
map.addLayer({
'id': 'circles',
'type': 'circle',
'source': 'tileset_data',
'source-layer': 'children_obesity',
'paint': {
'circle-color': '#7F3121',
'circle-opacity': 0.75,
'circle-radius': 5
}
});
Run Code Online (Sandbox Code Playgroud)
那么你就可以出发了。