chihsuanwu/google-maps-compose-web

Add marker clustering support

Opened this issue · 8 comments

Thanks for this really useful library!

I'm building a personal photo album website, and am using this library to display maps with up to several hundred photo markers on them. To help with the usability and responsiveness of this, it would be great to have support for clustering markers, as described here:

https://developers.google.com/maps/documentation/javascript/marker-clustering

I'm willing to have a go at implementing this myself, though it'll take me a while to find time and get up to speed on it. Thought I'd create an issue first to see if you have given this any thought already.

Hi,

Thank you for your suggestion. Currently, I don't have any immediate plans for this feature as I'm busy with another project. However, if you're interested, I'd appreciate you trying it out.

Additionally, if you're looking for inspiration or examples, you might want to check out the Android Map Compose API. I got a lot of inspiration from this library.

Ah thanks for the pointer to the existing Android API, I hadn't thought of checking that. It has clustering support, so looks very helpful.

FWIW - I haven't had much time to spend on this and am still finding my way around the Kotlin-JS integration side of things so haven't made great progress, however I do have a very basic demo working here. The code's a mess and most features aren't supported yet, I will keep chipping away at it when I can.

I think I will have some time in the next few days. Perhaps I can spend some time to give this a try. I'll provide updates here if there is any progress.

After experimenting with your POC and the original JS library, I found out that this is much more complex then I thought. While I haven't made much progress yet, I have formulated an idea: should we move this into a separate module, similar to Android's Map compose library?

The reason is not only because of the complexity of this functionality, but also it imports an npm module that basic map compose library not need. Hence, I believe this would be worthwhile. However, a drawback would be the necessity to relocate the jsobject folder into another module, as it's currently internal. (or just change them to public, but I think it's not worth).

Thanks for taking a look! Yes I can see it would make sense to separate jsobject out into a different module, no objections from me (or hopefully anyone else, as I don't think that change would break backwards compatibility?).

One challenge I hit was due to google-maps-compose-web not yet supporting all the underlying maps API functionality. For example, when clicking on a cluster, I wanted to zoom the map to the bounds of the items in that cluster using the underlying google.maps.Map.fitBounds() call. That doesn't seem to be exposed by google-maps-compose-web currently though, so a bunch of math is required to determine the center and appropriate zoom level instead. So I think to have good clustering support might require enhancements to the existing google-maps-compose-web features too?

I agree with the necessity of enhancements, and I believe I can work on this first. I will spend some time to first separate the jsobject. Afterward, I'll see which parts should be prioritized for enhancement (maybe Map's API first?).

Yes I'd agree the main Map APIs are probably the most important/useful.

To help keep things simpler on the clustering side, I think there's some functionality there that can be ignored for an initial version. For example, being able to change/implement different clustering algorithms probably isn't very useful to most people, given the default 'SuperCluster' algorithm is very good and what 99% of people will be happy with anyway.