[英]How I can I get geojson boundary array from existing layer using mapbox gl?
I am using one of the custom tileset of tilling service in mapbox.我正在使用 mapbox 中的耕作服务的自定义图块集之一。 I loaded that custom tile layer in map using below code.
我使用以下代码在 map 中加载了该自定义切片图层。
map.addSource('california', {
type: 'vector',
url: 'mapbox://xyz.california'
});
map.addLayer({
'id': 'terrain-data',
'type': 'fill',
'source': 'california',
'source-layer': 'california',
'layout': {},
'paint': {
'fill-color': 'black',
'fill-opacity': 0.5
}
});
Above code is filling out the inner area with black color.上面的代码用黑色填充内部区域。 But I want to fill out the outer area of that polygon.
但我想填写该多边形的外部区域。 Only one way I know to do that is getting difference of whole map with that polygon by using turf.js .
我知道的唯一一种方法是使用turf.js获得整个 map 与该多边形的差异。 After that I will be able to fill the outside area.
之后,我将能够填充外部区域。
Now the question is how can I get the geojson ploygon array of above added layer?现在的问题是如何获得上述添加层的 geojson ploygon 数组? So I can calculate the difference.
所以我可以计算差异。
You can't easily get the complete geometry of a polygon from a vector tile set, because it has already been cut up into tiles.您无法从矢量切片集中轻松获得多边形的完整几何图形,因为它已经被切割成切片。 You would have to either find a way to merge them together, or get your geometry into the front end as a complete geojson first.
您必须找到一种方法将它们合并在一起,或者首先将您的几何图形作为完整的 geojson 放入前端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.