React Google maps clusterer not working with dynamic marker data #380
sebastian-meckovski
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I didn't get any response on my StackOverflow post so I decided to post here.
I'm using this example, the only difference is that my dataset is not static, it can change and the markers are re-rendered.
It works only as long as the new markers passed to the clusterer are not intersecting with the already existing markers. So let's say we have a dataset of three items [1, 2, 3]. If we update the marker state data to [4, 5, 6] it handles it fine. But if update it to something like [2, 3, 4] it will throw
ReactJS: Maximum update depth exceeded error
because at least one item in this collection is present in the already existing marker dataset.Here is the reproduction of this on a React TS boilerplate
npx create-react-app my-app --template typescript
:packages used:
Here is my tsconfig.json
The reason I want to make it work like this is because my API is querying markers by a geohash + 8 nearest neighbours. So if I query by a neighbouring geohash, my the new returned data set will contain some markers that were already loaded in the previous query. So the client should ignore those. The animation below describes the desired workflow (minus the marker clusterer)
But if I implement the clusterer, it then breaks:
Notice that it only breaks if the loaded data is intersecting with the already loaded makers.
Not sure if this is a bug or something wrong with my implementation.
Is there a way to make the Marker Clusterer work with dynamic data set, where new data passed to the clusterer might contain markers that were already loaded in the previous service call?
Beta Was this translation helpful? Give feedback.
All reactions