Skip to content

Marker Cluster Plugin - #49

Merged
tobrun merged 1 commit into
masterfrom
tvn-clustering
Oct 21, 2017
Merged

tobrun merged 1 commit into
masterfrom
tvn-clustering

Conversation

@tobrun

@tobrun tobrun commented Jun 21, 2017

Copy link
Copy Markdown
Member

This PR ports 2 open-source clustering algorithms from googlemaps/android-maps-utils.

  • Non-hierarchical distance based algorithm
  • Grid based algorithm

ezgif com-video-to-gif 52

cc @mapbox/android

@zugaldia zugaldia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just small notes. I realize there're a bunch of TODO and UNSUPPORTED that probably come from the original library. I'd check which ones are worth ticketing. Otherwise, let's at least add a note saying something like "This TODO item was part of the original library (http://...), we welcome contributions if you want to work on it. See https://github.com/mapbox/mapbox-plugins-android#contributing for details."

Comment thread plugins/cluster/build.gradle Outdated
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0-beta.3@aar') {
transitive = true
}
// javadocDeps 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this left commented on purpose? Should we remove it instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setup was copied from the traffic plugin and will be required for release. Since there is a need for a final 5.1.0 of the map SDK (dependency on new OnCameraIdle API). I would leave this untouched until the release of this plugin.

package="com.mapbox.mapboxsdk.plugins.cluster"
>

<application android:allowBackup="true"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can remove the application tag from here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes 👍

import java.util.Map;
import java.util.Set;

// TODO: add OnMarkerDragListener

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

private Bounds createBoundsFromSpan(Point p, double span) {
// TODO: Use a span that takes into account the visual size of the marker, not just its

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a todo from the original implementation


private final Algorithm<T> algorithm;

// TODO: evaluate maxSize parameter for LruCache.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a todo from the original implementation

*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can remove this file.


final Set<MarkerWithPosition> markersToRemove = markers;
final LatLngBounds visibleBounds = mProjection.getVisibleRegion().latLngBounds;
// TODO: Add some padding, so that markers can animate in from off-screen.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a todo from the original implementation

for (final MarkerWithPosition marker : markersToRemove) {
boolean onScreen = visibleBounds.contains(marker.position);
// Don't animate when zooming out more than 3 zoom levels.
// TODO: drop animation based on speed of device & number of markers to animate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a todo from the original implementation

return null;
}

// TODO: make this configurable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a todo from the original implementation

private static final TimeInterpolator ANIMATION_INTERP = new DecelerateInterpolator();

/**
* Animates a markerWithPosition from one position to another. TODO: improve performance for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a todo from the original implementation

@tobrun

tobrun commented Aug 1, 2017

Copy link
Copy Markdown
Member Author

@zugaldia I was able to make the code work with a configurable flag for MarkerView though the performance wasn't great. I'm thinking on punting on Markers as we aim to deprecate MarkerView in upcoming releases in mapbox/mapbox-gl-native#9365.

@mdakram

mdakram commented Aug 1, 2017

Copy link
Copy Markdown
Contributor

Small issue with this plugin is there is no option to disable clustering at certain zoom level, say we need to plot 5 markers in 5 mtrs radius even at last zoom level we are not able to see all markers.

Is there any workaround for this?

@zugaldia

Copy link
Copy Markdown
Member

I'm thinking on punting on Markers as we aim to deprecate MarkerView in upcoming releases in mapbox/mapbox-gl-native#9365.

👍 on reducing the scope to markers for now.

@tobrun
tobrun force-pushed the tvn-clustering branch 7 times, most recently from a06a718 to 6bcfc42 Compare August 23, 2017 14:33
@simon1867

Copy link
Copy Markdown

Is there a timeframe on getting this PR merged? I'm currently in the process of migrating from Google Maps and this is one of the main features missing on MapBox for my usage.

@tobrun

tobrun commented Oct 20, 2017

Copy link
Copy Markdown
Member Author

@simon-the-canadian I'm working on rebasing this PR on latest changes of master.
Will merge once CI has approved.

cc @lilykaiser

@tobrun
tobrun merged commit f0d6e4a into master Oct 21, 2017
@tobrun
tobrun deleted the tvn-clustering branch October 21, 2017 08:52
@simon1867

Copy link
Copy Markdown

@tobrun Are you guys planning on releasing an artifact to maven soonish?

@maheshchakkarwar1

Copy link
Copy Markdown

When I run this code. Not working for me.
org.maplibre.android.exceptions.CalledFromWorkerThreadException: Map interactions should happen on the UI thread. Method invoked from wrong thread is latLngForPixel. at org.maplibre.android.maps.NativeMapView.checkState(NativeMapView.java:119) at org.maplibre.android.maps.NativeMapView.latLngForPixel(NativeMapView.java:713) at org.maplibre.android.maps.Projection.fromScreenLocation(Projection.java:96) at org.maplibre.android.maps.Projection.getVisibleRegion(Projection.java:153) at org.maplibre.android.maps.Projection.getVisibleRegion(Projection.java:122) at commichelin.clustering.view.DefaultClusterRenderer$RenderTask.run(DefaultCl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants