Mapbox-如何在Mapbox中添加.pbf文件作为图层



我想在Mapbox中的地图上添加一个平铺层。tiles是用php tileserver本地托管的。

我以前的尝试是这样的:

map.addLayer({
'id': 'tiles',
'type': 'fill',
'Source': {
'type': 'vector',
'tiles': ['http://localhost/tileserver-php-master/{z}/{x}/{y}.pbf'],
},
'paint': {
'fill-color': 'rgb(53, 175, 109)',
'fill-outline-color': 'rgb(53, 175, 109)'
}
});

瓷砖是应放置在地图上的单个多边形。地图是可见的,但不是单独的平铺。

geojson这样的层不是一个选项,因为文件大小太大了。

@Henhuy您可以将互动程序作为.mbtiles宿主,并使用:https://github.com/maptiler/tileserver-php.在那里,您还将看到源层的名称。

map.addLayer({
'id': 'uniqID',
'type': 'fill',
'source': {
'type': 'vector',
'tiles': ["LINK_TO_TILESEVER.pdf"],
},
'source-layer': "SOURCE_LAYER_ID",
});

最新更新