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

chunkedLoading doesn't work on subsequent updates #76

Open
shauravg opened this issue Jul 24, 2018 · 14 comments
Open

chunkedLoading doesn't work on subsequent updates #76

shauravg opened this issue Jul 24, 2018 · 14 comments

Comments

@shauravg
Copy link

I currently load the map with 0 markers while the marker data is being fetched from the backend. Once the markers are available, they are passed as children to MarkerClusterGroup. Even though I am loading quite a few data points (~10-15K) and using chunkInterval=50, I see no calls chunkProgress function.

If I don't render the map until the markers are available, then chunkedLoading works just fine. Let me know what details I could provide here to help solve this issue.

@yuzhva
Copy link
Owner

yuzhva commented Jul 24, 2018

What version of react-leaflet-markercluster do you use - 1.8.1 or 2.0.0-rc3?

@zach-ovic
Copy link

I'm having exactly the same problem, running 1.8.1.

@zach-ovic
Copy link

zach-ovic commented Jul 24, 2018

I've just tested 2.0.0-rc3 and I'm seeing the same results...

@zach-ovic
Copy link

My code:

<MarkerClusterGroup chunkedLoading={true} chunkInterval={100} chunkProgress={this.chunkProgress}>
    {
        clientsById && (
            Object.keys(clientsById).reduce<React.ReactNode[]>((result, key) => {
                const client: Client = clientsById[key];

                // Don't show clients without location
                if (!client.location) {
                    return result;
                }

                // Don't show clients that are inactive if the filter is turned on
                if (!areInactiveUsersVisible && !client.isActive) {
                    return result;
                }

                result.push(<ClientMarker key={client.id} client={client} />);
                return result;
            }, [])
        )
    }
</MarkerClusterGroup>

PS. sorry for spamming

@shauravg
Copy link
Author

shauravg commented Jul 24, 2018

I am using 1.1.8 and react-leaflet 1.8.2

@shauravg
Copy link
Author

Another update. I noticed that addLayers (where chunkedLoading is supported) is not called when the markers are sent as new props to the already mounted map and markerclustergroup component. Not sure why.

When I use a ref to manually call addLayers even if the markerclustergroup is already mounted, then it works fine. I don't know enough about the react-leaflet architecture to know if this is valid behavior or not.

@StazriN
Copy link

StazriN commented Aug 7, 2018

Is there any progress on the issue?

@yuzhva
Copy link
Owner

yuzhva commented Aug 7, 2018

@StazriN Did you try to use react-leaflet-markercluster@next next 2.0.0-rc3 version to reproduce that issue?

@StazriN
Copy link

StazriN commented Aug 8, 2018

Yes I did. Same problem.
chunckedLoading works only with first render when I change location or number of markers chunkedLoading doesn't work and everything freezes.

@radiallogic
Copy link

I'm also having this issue on 2.0.0-rc3

@ash-vd
Copy link

ash-vd commented Nov 20, 2018

Yep, same problem here (also 2.0.0-rc3).

@olabalboa
Copy link

Same issue for me. After looking at the code I notice that 2.0.0-rc3 doesn't support bulk adding of markers, see https://github.com/Leaflet/Leaflet.markercluster#bulk-adding-and-removing-markers.

Each time a child to MarkerClusterGroup is rendered the MapLayer from react-leaflet calls layerContainer.addLayer(). This causes severe performance issues for us when having about 2000 markers.

I forked this repo and modified the addLayer function to support bulk adding of many layers/markers (see code here https://github.com/olabalboa/react-leaflet-markercluster/blob/master/src/react-leaflet-markercluster.js).

Try it out if you like to see if it solves your problem. In that case I can open a pull request. Any comments or improvement suggestions are appreciated :-)

@radiallogic
Copy link

radiallogic commented Nov 27, 2018 via email

@radiallogic
Copy link

radiallogic commented Nov 27, 2018 via email

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

No branches or pull requests

7 participants