Skip to content

How to make drawn items appear on the top layer? #16

@Falke-Design

Description

@Falke-Design

Discussed in geoman-io/leaflet-geoman#1562

Originally posted by sarahjiang888 February 14, 2025
The library I use is MapLibre-Geoman
I am building a map layer by layer with geoman.mapAdapter.addSource & geoman.mapAdapter.addLayer function.
But when I try to draw rectangle / polygon / ..., those drawn items will appear under above layer
Is there any way to make drawn items always appear on top of layer drawn with geoman.mapAdapter.addLayer?

image

the blue one is actually a drawn rectangle, but it appears under the layer drawn with geoman.mapAdapter.addLayer function, and causes it be partial-hidden.

`

    const mapStyles: maplibregl.StyleSpecification = {
        version: 8,
        sources: {},
        layers: [
            {
                id: 'background',
                type: 'background',
                paint: {
                    'background-color': 'white',
                },
            },
        ],
    };

    let geoman: Geoman;

    try {
        map.current = new maplibregl.Map({
            container: mapContainer.current as HTMLElement,
            style: mapStyles,
            center: displayCenter,
            zoom: zoomLevel,
            attributionControl: false,
        });

        geoman = new Geoman(map.current, {
            settings: {
                controlsPosition: 'top-right',
                throttlingDelay: 100,
            },
        });
    catch (error) {
        //...
    }

    if (map.current) {
        map.current.on('gm:loaded', async function () {
            try {
                // add layer by layer with geoman.mapAdapter.addSource & geoman.mapAdapter.addLayer function
            } catch (error) {
                //...
            }
        });
    }

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions