rlayers icon indicating copy to clipboard operation
rlayers copied to clipboard

Generating RLayerVector objects outside of RMap

Open sl1g18 opened this issue 3 years ago • 2 comments

Hello, I am using this library in a React app where I am required to create components outside of my the RMap object. Is there any way, using RContext maybe, to generate RLayerVector objects outside of RMap and pass them in as children using the spread operator?

sl1g18 avatar Jul 26 '21 15:07 sl1g18

Currently, an RLayerVectordoes not support being detached and reattached to another RMap- this is the missing feature

mmomtchev avatar Jul 27 '21 11:07 mmomtchev

I think you need useRef for each RLayerVector in parent component, i'm working on that also, but the problem is when using RControl.Rlayer and you put RLayerVector inside or outside there with custom event handler yourself it's not work, I have code like this.

on parent component

const vector1 = useRef()
<RMap>
   <RLayerVector vector1Ref={vector1}/>
</RMap>

and then on your child component define ref on RLayerVector, and also mostly you can see that ref console.log(props.vector1Ref)

ngrhadi avatar Jun 16 '22 07:06 ngrhadi