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

Marker Clustering ServerSide #201

Open
Luigidefra opened this issue Sep 3, 2021 · 2 comments
Open

Marker Clustering ServerSide #201

Luigidefra opened this issue Sep 3, 2021 · 2 comments

Comments

@Luigidefra
Copy link

Hi, i have a little problem...
I have 400k points, i used PruneCluster to create Cluster and it very fast, the problem is that i have to send a 400k points json from server to client before to create Cluster with your application...
400k points are equivalent to 26mb and it too big to send to client...

I would like create Cluster on my server and then send only Cluster with your coordinates and counter...
is it possible refactoring code in PHP to run server side?

are there any other solutions?

@fungiboletus
Copy link
Member

Hello,

is it possible refactoring code in PHP to run server side?

Yes you can probably do. However if your data is never move or change, you can consider using another algorithm server side, based on https://github.com/mourner/flatbush or similar. PruneCluster is a good algorithm when you don't have that much data and it's dynamic/moving.

@mngyng
Copy link

mngyng commented Mar 24, 2022

What I did was copy the required functions from leaflet.js and include those onto the server. (Not all of them are needed and some of them are front-end specific, making it incompatible with Node.js.)

Following that I created three functions on the server side, for POST requests on "generating clusters", "collecting and doing statistics on members inside of markersArea", and finally "transfering all markers of a certain cluster from backend to frontend if spiderfied (expanded from a cluster into markers)".

Then on the frontend I modified the PruneCluster.js to be included on the client side, making it capable of interacting with the services above.

I ended up with a MESSY CODE that processed a GeoJSON dataset of 100k points/63MB.

Nevertheless, I'll have to say, IT IS SATISFYING to see it actually works.

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

3 participants