terra-draw
terra-draw copied to clipboard
[Enhancement] Keep layers on top (Mapbox/Maplibre)
trafficstars
If you add layers to the map while you are using terra draw in maplibre or mapbox then those layers could be added above terra draw ones. It would be nice to have them always on top.
One solution could be implemented at the end of render method of mapbox gl adapter
// Make sure terradraw layers are on top of all others
["point", "linestring", "polygon"].forEach(geometryKey => {
const id = `td-${geometryKey.toLowerCase()}`;
if (this._map.getLayer(id)) this._map.moveLayer(id);
if (geometryKey === "polygon") if (this._map.getLayer(id + "-outline")) this._map.moveLayer(id + "-outline");
});
Hey @alanOracle - thanks for this! Think you are saying you want to keep the Terra Draw layers on top right?
Affirmative.
I'm going to close this in favour of [Feature Request] Control layer and feature ordering in MapLibre/Mapbox #394 which would mean making it configurable.