0
votes

I am using one of the custom tileset of tilling service in mapbox. I loaded that custom tile layer in map using below code.

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. 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? So I can calculate the difference.

1

1 Answers

0
votes

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.