terra-draw icon indicating copy to clipboard operation
terra-draw copied to clipboard

[Enhancement] Keep layers on top (Mapbox/Maplibre)

Open alanOracle opened this issue 2 years ago • 2 comments
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");
});

alanOracle avatar Jul 24 '23 21:07 alanOracle

Hey @alanOracle - thanks for this! Think you are saying you want to keep the Terra Draw layers on top right?

JamesLMilner avatar Jul 24 '23 22:07 JamesLMilner

Affirmative.

alanOracle avatar Jul 24 '23 22:07 alanOracle

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.

JamesLMilner avatar Jan 20 '25 20:01 JamesLMilner