rlayers icon indicating copy to clipboard operation
rlayers copied to clipboard

ask for feature: add option to RControl.RLayers to make it non-collapsable. or is it already possible?

Open gillesserco opened this issue 3 years ago • 5 comments

Hello

First: thank you for this great library. Very useful...

I would like to have the RControl.RLayers control expanded all the time. is it already possible with the current code( or with css change)? If not does it make sense to make a modif to pass some option like 'collapsable: true/false'?

Then as I some time I struggle a lot to find how to do use some component(and then maybe I use it in not the best way), is it possible to contact you directly (without abusing of your time of course). Or is there some discussion group or equivalent somewhere?

Thanks

best regards

Gilles ([email protected])

gillesserco avatar Jun 12 '22 09:06 gillesserco

You can submit a PR, but otherwise you can simply pass an empty element for the collapse button and then manually click it once at initialization:

const ref = React.useRef<RControl.RLayers>(null);
React.useEffect(() => {
  if (ref.current) ref.current.clickCollapse();
}, [ref.current]);

return <RControl.RLayers ref={ref} element={<span />} />;

mmomtchev avatar Jun 12 '22 10:06 mmomtchev

Hello

Thanks, it is working. The only drawback I see is that it trigger a re-render of the map. And so I have a refresh related question: I see two rendering of the RMAP component, usingminimum RMAP structure: single layer <ROSM> inside it or even RMAP with no children.

( I am trying to figure out what trigger a map re-render (i.e. is it normal or is my code broken), like adding features inside a RLayerVector... )

gillesserco avatar Jun 14 '22 14:06 gillesserco

Can you post your code?

mmomtchev avatar Jun 14 '22 21:06 mmomtchev

Hello

I have another question on the layer control component: if it contains just one layer, by default the layer is selected and visible, perfect, But what if I want to hide this layer? Deselecting it is not possible, do you have some code that can do this when the used click on the layer checkbox?

In my case I have 2 Rcontrol.Rlayer in my app: one for base maps + one for imagery layer(s) on top of the base map. I may have just one imagery layer, and I need in any case to have a show/hide capability on the imagery layer(s). ( I also thought of adding a 'empty' layer in the control, which would probably solve my problem)

Thanks for any info.

gillesserco avatar Dec 01 '22 11:12 gillesserco

You can set visible={false} on the layer

mmomtchev avatar Dec 01 '22 16:12 mmomtchev