-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Map dragging is slow when using more than 15 000 markers in a high zoom level #29
Comments
I think I know why: the markers are distributed all over the the earth and clusters are calculated for all of them although only a small area is visible for the user. So imho a fix would be that clusters are only computed in the visible area. |
Thanks for reporting! This is roughly fixed in HEAD, but needs more work, and is why v0.2 (which includes clustering) hasn't been widely publicised. Stand by. :-) |
Also, very curious what you're doing with 15K markers - feel free to mail me privately if you don't want to talk about it here. |
Seems like adding a simple |
Working on this next. |
Hey, |
I have encountered a similar problem with this myself, but it was with polylines. And here's what I did. I'm sure for markers, this can be implemented, or maybe implemented already in the library... |
Thank you. Using the idea of your solution helped me improve performances. |
I also have implemented @ericpanorel's solution to greatly improve the performance of clustering with a large data set. I'm using a custom I would be interested to know if my workaround is the right way of doing things, seems to me like this functionality should be baked into the clustering algorithm somehow? Thanks. |
could anyone of you post the code for doing this? I think it'd help many of us! |
Ok I tried it myself. The following code clears all items from the clustermanager and then dynamically checks if markers are in the visible area of the map after a camera position change. If they are, they are added to the clustermanager. This happens in an asynctask and the performance acceptable (at least on a Nexus 7) with ~ 20.000 Markers: private class DynamicallyAddMarkerTask extends AsyncTask<LatLngBounds, Void, Void> { @OverRide storkme: how did you scale the bounds to be 1.5 times larger than the visible screen area? But somehow it doesn't work when I'm above the equator? Greetings and thanks for the great library! |
I think it had to do something with too long distances. When i keep them about 2.000.000 meters it works! @broady are you going to include something like this in the clustermanager/alghorithm? Thank you for the library! |
I'd also like to suggest that the Algorithm interface include a cancel() member, and that ClusterManager.cluster() call it to stop any previous expensive clustering operations. It makes a difference when the user makes multiple rapid camera changes, e.g. zooming or panning. Better than relying on Java to kill the ClusterTask background thread IMO. |
Is there any practicable solution for this issue yet? |
Any word on this? I have about 8k markers and the lib is unusable at that point unfortunately. And I say unfortunately with great respect as this is a beautiful lib as far as UI, very easy to use and documented well. Really hoping I can use this soon :( At a high level zoom things are pretty good. However as I start to zoom in performance degrades. I assume this is due to markers and clusters off the viewport being drawn/redrawn as I zoom. Then once I am zoomed all the way in if I zoom out quickly I notice a huge hit. All the markers are unclustered (as I was all the way zoomed in before). I keep zooming out until I can see the entire map. I can see all (unclustered) markers and it takes 20-30 seconds to loop through all 8K markers and place them back into a clusters. All of this probably relates to the fact that off screen markers and clusters are being drawn. However I also wonder if this is slow due to the animations. In cases like this it might make sense to be able to turn off animations and just remove and redraw all clusters and marker on zoom change. |
I made the following changes locally to get the library to work reasonably
I like this library but I wish the team were more responsive to obvious On Mon, Apr 6, 2015 at 6:44 PM, Billy Newman notifications@github.com
|
@akirmse agreed, wish issues like this would get more attention. Of course I am not contributing so I can't really complain ;) Is this being actively worked by contributors, or has anyone forked, maybe a possible PR for this? |
For more than two years the clustering element of this library is totally unusable. Clustering more than 100 items even on a big area brings huge performance issues. This should be either adressed or removed completely from the library. The suggestion by @akirmse does significantly improve the performance of this library. |
Heres my hacked version :
Add the following if to the QuadItem candidate for each loop
Replace ClusterManager.cs onCameraChange function with the following:
|
@akirmse can you show your example in code? |
@broady any update on this one? Your clustering looks very cool, the animations are great, but it just cannot handle more markers. And this is a big problem, since the point of clustering that we have lots of markers. I am currently using this algorithm to only cluster the visible markers, but this also has drawbacks (clusters change a lot, user have to wait a little bit when cluster show up after changing camera). |
I had to modify this library to my needs to get it working. I turned off animation and have it refreshing async on camera change. I have about 50k+ markers and it works great. It will only show markers in the visible region. |
Hey folks. I've actually left the Maps team, so everything I do on this project is in my spare time. Here's what I think should happen:
Unfortunately the loose coupling design of the library isn't conducive to this kind of stuff. I think it was a mistake. @jfschmakeit @markmcd in case they have spare cycles. |
Anyone on maps team supporting this or is it left to die? |
@newmanw I've just written down the exact steps of my preferred solution. Please discuss, send a pull request, etc! :) |
@broady it is sad you no longer work on this officially, and no one else took over. This is an important project, even referred from the official doc. Thanks for still managing the project, your time is much appreciated! I already tried to implement your solution, but only in a very naive way. @Override
public void onCameraChange(CameraPosition cameraPosition) {
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
for (Marker marker : clusterManager.getClusterMarkerCollection().getMarkers()) {
if (bounds.contains(marker.getPosition())) {
marker.setVisible(true);
} else {
marker.setVisible(false);
}
}
} There are two problems with this approach:
So a more complicated solution is needed, but i could not figure that out. |
+1 for this issue |
With help of stephenmeyer's hack I implemented my version of viewport only clustering which is lightning-fast. Here is a detailed description of all my changes. So, create a class in android/clustering. I called mine bvb.java and this is the content:
This holds 2 variables that can be accessed anywhere within the clusterManager. Now edit ClusterManager.java
Find the onCameraChange method and change it to the following:
We first load the viewport bounds into a variable. I increased the viewport with 15% so that the corners also show markers/clusters and panning shows at least some data to the sides. Just 15% extra won't hurt performance. You can play with this number and increase/decrease it to your liking. Now edit algo/NonHierarchicalDistanceBasedAlgorithm.java.
In the getClusters method find the line "for (QuadItem candidate : mItems) {
While iterating over all map-points, this doesn't process any point outside your viewport + the 15%. Then edit algo/PreCachingAlgorithmDecorator.java.
The cluster-results are cached per zoomlevel. Since we now have viewports-clusters, this no longer works. I thought about caching by zoomlevel and viewport-coordinates, by the chance of hitting the exact same combination multiple times is slim and since it already performs pretty well I decided to disable caching completely. I didn't back-out the caching-code but went for the quick approach of just disabling saving to cache so it will never find any cache. Here is an archive with the changes files. Bo |
As one solution to slow animation you can now choose to disable the animations, which was added in 27f7a5b |
I've a map with 4k markers on it. I've tried the VisibleBasedAlgorithm but the performance remains very very slow. My experience:
Is there a way to avoid the cluster expansion when the markers aren't visible on maps bounds? I think that this could be only solution. |
@CeccoCQ, you can try this optimised variant of Screen Based algorith zamesilyasa@8694da3. |
Hi @Gary111, By your experience, is there a way to increase the bitmap drawing performance? |
Are you sure you are using as small bitmaps(thumbnails) for markers as possible? if bitmap is large, it will slow rendering down. |
@CeccoCQ, If you mean drawing markers, I use disk and memory LRU cache for this. So I generate icon only once and save it in cache, next time I just extract it form cache. It increases performance a little. |
Hi, thanks for your responses. This is my code used to create the bitmap (into MyRenderer constructor):
then into the onBeforeClusterItemRendered method:
The original bitmap is a png file of 294x294px of 15Kb |
So... over 4 years down the line is there any progress on this issue?? |
I am facing the same issue. Dragging too slow when zooming out. Is there any way to fasten this? |
The fact this issue has been open for 5 years and the lack of response from anyone suggests this will not be addressed. I’d recommend a 3rd party clustering library if you want something that works. |
I can confirm, this https://github.com/mg6maciej/android-maps-extensions/tree/develop can handle a lot of markers without performance issues |
Having used android-maps-extensions and google-maps-clustering I would recommend the following: https://github.com/sharewire/google-maps-clustering Performance is fantastic and the code is well written and easily extended. Also has nice animations when the map moves and the clusters regroup. |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution. |
Hey,
I have (sometimes) much more than 15 000 markers. When i drag the map in a high zoom level e.g. above an area that has only like 200 (clustered) markers it is very slow although I have a Galaxy S3. Someone knows how to make dragging fast in high zoom levels?
The text was updated successfully, but these errors were encountered: