Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gillesserco opened this issue Jun 12, 2022 · 5 comments

Comments

@gillesserco
Copy link

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 (gilou3000@hotmail.com)

@mmomtchev
Copy link
Owner

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 />} />;

@gillesserco
Copy link
Author

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 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... )

@mmomtchev
Copy link
Owner

Can you post your code?

@gillesserco
Copy link
Author

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.

@mmomtchev
Copy link
Owner

You can set visible={false} on the layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants