-
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
Render only visible items on the map #217
Conversation
…lgorithm. Sow screen size is based on display, but not on map left and right corners coordinates.
@broady or @markmcd could you rerun this build on Travis? The initial build failed with |
Thanks, looks like the Travis build passed now. I've been seeing occasional failures due to |
+1 for merge |
+1 |
Mark or @jfschmakeit can you look at this more closely? |
Awesome - thanks for this contribution. It's looking great on the device. Just a couple of comments around the code. Oh and I'll re-run the Travis builds when needed, they're very flaky at the moment. |
cluster(); | ||
} | ||
|
||
public void setClusterOnlyVisibleArea(boolean onlyVisibleArea) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that a user should have to provide an algorithm as well as specifying this property. Can you refactor such that this property is defined on the Algorithm implementation? e.g. add a method to Algorithm like boolean shouldReclusterOnMapMovement()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about back compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we could use Java 8 we could add a default method to the interface, but alas that's not an option.
How about extending Algorithm (e.g. ViewBasedAlgorithm
) and use that to determine instead. You may even be able to move the onCameraChangeListener code in there, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this variant too, but in this case I will have to use instanceof to check, if this algorythm is ViewBasedAlgorithm, but if this algorithm will be decorated(like you do with PreCachingAlgorithmDecorator), it will not work at all. That's why I removed this decoration by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, good point. My main concern is that the behaviour of using setClusterOnlyVisibleArea
on anything other than the new Algorithm you've introduced is undefined.
The only other option available is to break the Algorithm interface by adding the method suggested above. I've thought about this a bit and I think that it's the right thing to do but I (or whoever releases the next version to Maven) will need to make sure we bump the version number appropriately so it's clear what's happening.
What do you think about that? Reasonable? Or too drastic?
FYI - looks like the Travis timeout issue should hopefully be fixed in |
ScreenBasedAlgorithmAdapter is now derived from NonHierarchicalDistanceBasedAlgorithm Added new ScreenBasedAlgorithm interface. Implementing this interface, Algorithm has map position and can skip clustering if it is not required. Removed usage of instanceof checks in ClusterManager, which broke algorithms logic, in case of decorations. googlemaps#82
I think the getVisibleBounds() method in the VisibleNonHierarchicalDistanceBasedAlgorithm class not working correctly. On bigger screens the bounds not matching to the screen and the displayed area with markers is more bigger. I've tried to fix it with getVisibleRegion() method and calculation, but if user rotate the map, this solution is not working :) |
What screen size/dimension do you use? |
I've checked with a 480x800 and a 1920x1080 resolution. Now, I've solved with this code: Something wrong with code insertation :( private Bounds getVisibleBounds(int zoom) {
|
I believe you use too old code. I don't use map bounds anymore. Please, pull the latest version of the patch |
Okey, thank you! |
Any idea when this is gonna be merged? |
Is it a part of the plan to integrate / merge this functionality? |
I am just trying to keep it up to date |
Is there any reason not to merge this? (besides perhaps squashing commits) |
Commits will be squashed by merge, isn't it? |
Someone with merge rights could, indeed. |
If an Algorithm reference is already a ScreenBasedAlgorithm, then it can be passed as is to setAlgorithm(ScreenBasedAlgorithm). Only if it is not already a ScreenBasedAlgorithm is it then wrapped with a ScreenBasedAlgorithmAdapter.
…m-wrap Don't wrap Algorithm if already implements ScreenBasedAlgorithm
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
@googlebot I consent to have my commit merged to this project. Looking forward to having this pull request as well as my other two that are pending merged into the base project. |
@zamesilyasa I noticed that |
@b1n0m13
That's the core idea of the algorithm - recluster on map movement. If you will disable this in case popup is shown and scroll the map, you will see an empty square of the map, what breaks consistency between visual representation and data set |
@markmcd |
Will this be merged with main code? |
This is merged now, thanks all. |
Will there be new release with these changes? |
Is there any plan to release this as part of next release? Managing gradle dependencies are much easier than moving the aar in multiple project. |
I also want to use this feature in my project with gradle dependencies. Please release it ! |
+1 Would love this |
Implemented rendering only visible items on the map(issue #82 )
Added VisibleClusteringDemoActivity activity which demonstrates clustering of 20k items.