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

Performance issues with RDraw #158

Closed
PaliMartin opened this issue May 22, 2023 · 4 comments
Closed

Performance issues with RDraw #158

PaliMartin opened this issue May 22, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@PaliMartin
Copy link

I get performance issues (mouse pointer starts lagging) when I add an Rdraw element to the map component. Works when I use pure openlayer. Any ideas on what could be causing this?

export const RlayerMap = memo(() => {
    const origin = [2.364, 48.82];
    const initial: RView = { center: fromLonLat(origin), zoom: 11 };

    return (
        <div style={{ height: 800, width: "100%" }}>
            <RMap
                width={"100%"}
                height={"100%"}
                initial={initial}
                noDefaultControls={true}
            >
                <RControl.RLayers>
                    <RLayerTileWebGL
                        properties={{ label: "OpenTopo" }}
                        // url="my url"
                        attributions="Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)"
                    />
                    <RControl.RZoom />
                </RControl.RLayers>
                <RLayerVector>
                    <RInteraction.RDraw type={"Circle"} />
                </RLayerVector>
            </RMap>
        </div>
    );
});
@mmomtchev
Copy link
Owner

Alas, this is a very error-prone optimization and the difference is barely noticeable - it comes mostly because Chrome emits a warning. I prefer to not do this especially since it will be valid only when the interaction is empty - once you add any processing to this interaction, the performance is the same as raw Openlayers.

@mmomtchev mmomtchev added the enhancement New feature or request label May 30, 2023
@mmomtchev
Copy link
Owner

@PaliMartin Which version of Openlayers are you using? 7.3.0 has a number of improvements - including suppression of the Chrome warning - and it is marginally faster.

@mmomtchev
Copy link
Owner

If you don't use pointer move events in your application, you can somewhere in the initialisation before the map is created (it is fine in the global context):

RFeature.pointerEvents = ['click'];

This will increase performance if you have a layer with lots of features.

@mmomtchev
Copy link
Owner

Addressed in #165

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

No branches or pull requests

2 participants