-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Is it possible to dinamically add/remove layer from RMAP? #184
Comments
Both should work using regular React semantics - you rerender your component without the layer or with the a different url. <RMap>
{ layerPresent && <RLayer url={dynamicUrl} /> }
</RMap> It something does not work, it is a bug. |
Hello Sorry but it is still not clear to me, or maybe my question is badly formulated. In my tests I used reference to the rmap object to acces his context/content and change url on the fly onRLayerTileWebGL, or add geo-featrures in RLayerVector, and this his working well, but creating/removing layers would have been simplier if possible. For the purpose of this question, my minimum code is like this:
Thanks |
This is a basic React question. It will be the same with any HTML element, not only maps: function Component() {
const [show, setShow] = React.useState(false);
return (
<div>
<button onClick={() => setShow(false)}>Remove</>
<button onClick={() => setShow(true)}>Show</>
{ show && <div>Element that goes away</div> }
</div>
)
} |
hello, Yes I know this, unfortunately I looks like I don't manage to communicate what my problem is... Basically I want the equivalent of the openlayer map.addLayer(raster) method... Thanks anyway |
This is it, you create a map with a layer that can be added and go away. A layer is a sub-element of a map. |
you might also use visible prop to make layer visible? |
You can handle a layer the same way you handle any other HTML element. When the element disappears, so does your layer. |
Hello
I have built a webapp + backend that displays COG GeoTiff ( http://141.95.153.253/rapidai4eo/index.html ).
I didn't find a way to dynamically add or remove layers (in particullar RLayerTileWebGL) on a RMAP.
My workarround is to create the RMAP with n RLayerTileWebGL, then to change the layer URL dinamically as needed.
So is it possible? if so can an example be added?
Thanks and best regards
Gilles
The text was updated successfully, but these errors were encountered: