Avoiding Duplicate Features in Extended TileLayer
rendering GeoJsonLayer
#8790
-
I've created The issue is, some of the features show up more than once because a single Each feature has a unique What’s the best way to make sure each feature only gets shown once? In the drawing below,
It will end up looking something like this. Simplified version of my fetching logic getTileData(tile: _TileLoadProps): Promise<FeatureCollection> | null {
const boundingBox = tile.bbox as GeoBoundingBox;
const data = fetchByBoundingBox(boundingBox);
return data as Promise<FeatureCollection>;
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The basic idea of the Well, that is easier said than done, with a few catches here and there. The generation of tiles is most commonly done on a server, and transmitted with a protocol other than GeoJSON, for example, check out the |
Beta Was this translation helpful? Give feedback.
The basic idea of the
TileLayer
is that you do not fetch or display data that is out of view. This means that you never return the whole feature when it spans multiple tiles. You are supposed to crop that feature and only return the portion that overlaps with the given bounding box.Well, that is easier said than done, with a few catches here and there. The generation of tiles is most commonly done on a server, and transmitted with a protocol other than GeoJSON, for example, check out the
MVTLayer
which extendsTileLayer
to handle the MVT tile format. If you have to do the tile slicing on the client side, there are tools like geojson-vt. I put together a simple demo here.