This code is an attempt to reproduce an excellent code by jawj, in Java, intended to be used on Android, alongside the excellent android-maps-extensions.
For a thorough documentation please refer to jawj’s OverlappingMarkerSpiderfier repository.
The actual code was last updated on 12-March-2014.
Before proceeding to read \ use the code, please consider the following:
- Since the original library is written in JavaScript (JS), and considering I had absolutely zero knowledge in JS and in CoffeeScript (CS) when undertaking this, it is very likely that some things got lost in translation.
- I was following the original flow of the CS (more or less). I pretty much worked blindly without much filtering of what’s relevant to Android and what’s not so expect some redundant code. The upside of this method is, however, that the original comments\documentation apply quite well.
- Any relation between what you are about to see and “proper” Java code is purely coincidental. Make sure you’re sitting before proceeding.
- The code is absolutely unoptimized in terms of memory\performance.
- Any functionality customizations (such as Polyline properties, radii, etc.) must currently be changed via hardcoding.
- You will have to put up with my sarcasm.
Having managed your expectations, this code:
- Works. And is very stable at that – inside are merely 2 try-catch blocks, which I’m not sure are even needed.
- Has ample room for improvement if you’re up for it. Any help will be appreciated!
See sample app. Make sure you have a valid Google Maps API key.
- This class Overrides the map’s
OnCameraChangeListener
. If you have your own listener, just move the code from the class’ built-in listener to your own. - The developer is assumed to be working with android-maps-extensions.
- It is highly advised to control the zoom at which spiderfication occurs (i.e. switch the
OnMarkerClickListener
’s behavior from zoom to spiderfication only after a certain zoom level). - Spiderfication only works on
instanceof ClusterMarker
. - Unspiderfication is performed on zoom level change (hence the aforementioned listener override) & if another cluster is clicked.
Watch several demos on YouTube:
h3 Known Bugs
- For certain combinations of
GoogleMap.clusterSize
andCameraPosition.zoom
clusters are only partially clusterfied (i.e. the result is a cluster with one ore more polylines sticking out of it).
- Rewrite the class keeping only functional methods.
This software is released under the APACHE LICENSE 2.0.