mapboxer icon indicating copy to clipboard operation
mapboxer copied to clipboard

Remove or update a layer

Open pepcmarques opened this issue 1 year ago • 0 comments

After adding a layer with add_fill_layer, it would be good to be able to update it and/or remove it to be replaced.

map boxer(....) |>
       add_fill_layer(fill_color = fill_color(col),   # Function that fill geographic areas based on a column
                   filter = custom_filter(col),              # Function that filters based on a column
                   id = "fill-layer",
                   popup = custom_popup(col)         # Function that creates a custom popup

The pattern above works well. But, I couldn't find a way to update/remove it on mapboxer_proxy.

mapboxer_proxy("myMap")  |>
        set_paint_property("fill-layer", "fill_color", fill_color(col) ) |>
        update_mapboxer()

This can update color, but both set_paint_property and set_layout_property don't update popup.

The idea would be to have an update_fill_layer (ideally) and/or a remove_fill_layer as here so it could be added again.

Controlling visibility could be a solution, but it would require for the program to control layer id depending on events.

pepcmarques avatar Feb 13 '24 19:02 pepcmarques