Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Point annotation clustering #5814

Open
1ec5 opened this issue Jul 28, 2016 · 42 comments
Open

Point annotation clustering #5814

1ec5 opened this issue Jul 28, 2016 · 42 comments
Labels
annotations Annotations on iOS and macOS or markers on Android clustering Core The cross-platform C++ core, aka mbgl Google Maps parity For feature parity with the Google Maps SDK for Android or iOS MapKit parity For feature parity with MapKit on iOS or macOS

Comments

@1ec5
Copy link
Contributor

1ec5 commented Jul 28, 2016

The longstanding “GL point annotation” API (exposed as MGLPointAnnotation on iOS and macOS, Marker on Android, and PointAnnotation on Qt) should support options for marker clustering. The GeoJSON point clustering implemented in #5724 is important for parity with Mapbox GL JS, but its use will be somewhat limited until this functionality is extended to point annotations, which have a few important advantages over GeoJSON points:

  • Point annotations can display images that are loaded or even generated at runtime. GeoJSON points can only display images that come with the style (for example, images that are managed in Mapbox Studio). Therefore, it isn’t possible to use a GeoJSON point to represent the current user’s avatar on the map or to draw text into an image and use that image in a GeoJSON point.
  • An application may need to add, remove, and modify annotations very frequently during the course of a map’s lifetime. With a GeoJSON layer, to add, remove, or modify an annotation, you have to blow away the entire layer and reconstruct it. Therefore, it isn’t feasible to animate GeoJSON points smoothly, and it’s very tedious to implement a “long press to drop pin” UI using GeoJSON points exclusively.
  • MGLPointAnnotation and Marker have built-in support for interactivity, opening a popup when tapped. GeoJSON points require the developer to handle gesture recognition, selection, and spatial querying with custom code.

Based on its unique behaviors, mbgl::SymbolAnnotation could not be reimplemented using GeoJSON layers. However, as long as Supercluster is extended to support dynamically changing markers, SymbolAnnotation could use Supercluster much the way GeoJSON layers do now.

We’ll need to add public APIs to the SDKs for configuring marker clustering.

/cc @mourner @jfirebaugh @mapbox/mobile

@1ec5 1ec5 added Core The cross-platform C++ core, aka mbgl annotations Annotations on iOS and macOS or markers on Android labels Jul 28, 2016
This was referenced Jul 28, 2016
@danetch
Copy link

danetch commented Aug 12, 2016

Hi,
any eta for this ?
thanks !

@1ec5
Copy link
Contributor Author

1ec5 commented Aug 12, 2016

This work is currently blocked by mapbox/supercluster#19.

@ShaunBaker
Copy link

Hello

Any updates on this?

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Sep 14, 2016

Thanks for your interest folks. If there is nothing posted here or in the ticket linked above, you can assume there are no updates. We will post when there is.

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 27, 2016

If the performance and memory considerations in mapbox/supercluster#19 (comment) would require a painful tradeoff for the usual case of a static point layer, I wonder if it might be possible to stick to the KDBush algorithm: we could “dirty” the clustering index on each annotation addition, modification, or removal and lazily rebuild the index when the zoom level changes.

@AAverin
Copy link

AAverin commented Oct 7, 2016

Any workaround, except GeoJSON, I could apply to have clustering in Android application with MapBox SDK?

@ttoni
Copy link

ttoni commented Oct 21, 2016

First we had to completely rebuild our maps from image to vector (mapbox studio), then we had to wait for customized marker icons, now we have to wait for marker clustering. It was all possible with the old mapbox sdks and an important factor why we switched to mapbox.
the transition from the old to the new sdk really is a huge tradeoff for our company. Better visual representation through vector, but missing some very basic features that were already there in old mapbox sdk.

So is there any chance, that we might see clustering again in ios/js/android in the next months?

@nitrag
Copy link
Contributor

nitrag commented Oct 25, 2016

+1 in same boat. Crucial features for my application if I'm going to switch
to Mapbox SDK.

On Oct 21, 2016 9:44 AM, "ttoni" [email protected] wrote:

First we had to completely rebuild our maps from image to vector (mapbox
studio), then we had to wait for customized marker icons, now we have to
wait for marker clustering. It was all possible with the old mapbox sdks
and an important factor why we switched to mapbox.
the transition from the old to the new sdk really is a huge tradeoff for
our company. Better visual representation through vector, but missing some
very basic features that were already there in old mapbox sdk.

So is there any chance, that we might see clustering again in
ios/js/android in the next months?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#5814 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMBkkg_fshiFe6ZBGHReOi5MWqPSWc2ks5q2MGtgaJpZM4JW21O
.

@danetch
Copy link

danetch commented Nov 14, 2016

Hi,
Can you guys please give us an eta ? I need to know whether I must implement it myself, or if that work is likely to surface in the coming weeks. More to the point, will it see the light before beginning of Feb 2017? thanks !

@cammace
Copy link
Contributor

cammace commented Nov 14, 2016

You can do point clustering already using the latest SDK betas and runtime styling. Checkout this example in the Android demo app (the same can be done on iOS).

@danetch
Copy link

danetch commented Nov 14, 2016

Thanks, that looks like good news :) Stupid follow up question: You are using a GeoJsonSource in this example. Are you implying that the proper way of creating clusterable annotations is through GeoJson, and that we have to format the markers we want clustered as a geojsonstring to be fed as geojsonsource to the mapboxmap ? is it how it is intended to work ? Thanks for your help !

@cammace
Copy link
Contributor

cammace commented Nov 14, 2016

This is currently the only way to cluster icons at this point. This ticket is specifically for exposing clustering through GL markers which we are looking to add in the future. Feel free to reach out through our contact page if you have any additional questions.

@1ec5 1ec5 added the clustering label Dec 7, 2016
@mourner
Copy link
Member

mourner commented Jan 19, 2017

we could “dirty” the clustering index on each annotation addition, modification, or removal and lazily rebuild the index when the zoom level changes.

Batching will certainly help. But not only on zoom level changes — when you add an annotation, you want it to be reflected in the current view immediately without changing the zoom.

@incanus
Copy link
Contributor

incanus commented Feb 8, 2017

Much of the OP is irrelevant now given runtime styling and shape sources, but the interaction point is quite relevant still for in-GL layers vs. the annotations API.

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 8, 2017

The original post was written entirely with runtime styling and shape sources in mind. 😉

Point annotations can display images that are loaded or even generated at runtime.

Implemented for runtime styling in #6436.

An application may need to add, remove, and modify annotations very frequently during the course of a map’s lifetime. With a GeoJSON layer, to add, remove, or modify an annotation, you have to blow away the entire layer and reconstruct it.

This is still a dealbreaker for many use cases that involve data generated piecemeal at runtime: #6177.

MGLPointAnnotation and Marker have built-in support for interactivity, opening a popup when tapped.

#6515 and #4392 would mitigate the issue somewhat, but the fundamental issue is that the runtime styling API isn’t as object oriented as the annotation/overlay API.

@dchersey
Copy link

Can anyone comment on whether they have tried using an external (separate) clustering algorithm to determine the set of annotations rendered on MapBox-native? On the surface, it doesn't sound too hard; I use an open-source solution right now with MapKit that is pretty good. Adapting it to MapBox would be a matter of marrying MapBox's annotation APIs with the controllers in that solution.

@Zakay
Copy link

Zakay commented Apr 12, 2017

+1

@barrylachapelle
Copy link

+10

@fffaria
Copy link

fffaria commented Apr 27, 2017

So, is there a way to create clusters with markers created in the mapbox itself? I really need to have that into my University's app.

@1ec5
Copy link
Contributor Author

1ec5 commented Apr 27, 2017

So, is there a way to create clusters with markers created in the mapbox itself?

Yes, but you’ll need to use the runtime styling API instead of annotations, specifically MGLPointFeature, MGLShapeSource and MGLCircleStyleLayer. Here’s a rather involved example that relies on a bundled file, but hopefully you can adapt it to your needs.

@fffaria
Copy link

fffaria commented Apr 28, 2017

@1ec5 Sorry, I forgot to mention that I am using Android only, not iOS!

@fffaria
Copy link

fffaria commented Apr 28, 2017

@1ec5 I spent a lot of time trying to make it work with my markers but I did not manage to make it work with the markers I got. Is there any way, like other APIs, that I could use that could organize my markers when I zoom out? I have 191 markers close to each other, if the user zooms out, it gets really messy!

@1ec5 1ec5 added the Google Maps parity For feature parity with the Google Maps SDK for Android or iOS label Apr 28, 2017
@AAverin
Copy link

AAverin commented May 4, 2017

Asking the same question here half a year later.
Any progress on clusterring support without GeoJSON? This time I am about to start making iOS app and was hoping to use MapBox for maps.

@dchersey
Copy link

dchersey commented May 4, 2017 via email

@nitrag
Copy link
Contributor

nitrag commented May 4, 2017

+1 on vector clustering!

@ttoni
Copy link

ttoni commented May 4, 2017 via email

@Sealos
Copy link

Sealos commented May 4, 2017

+1.0

@jamesedmonston
Copy link

+1

1 similar comment
@askarsyzdykov
Copy link

+1

@1ec5 1ec5 added the MapKit parity For feature parity with MapKit on iOS or macOS label Jun 5, 2017
@tobrun
Copy link
Member

tobrun commented Jun 22, 2017

Adding here that until the core implementation for this has landed. You can workaround this on Android using the following plugin. Note this is still a WIP, no release out on maven.

ezgif com-video-to-gif 52

@jaltin
Copy link

jaltin commented Oct 19, 2017

+1

@friedbunny
Copy link
Contributor

Thanks for everyone’s interest, but GitHub issues are not a voting platform and “+1” is not a useful contribution — if you wish to follow the progress of this issue, hit the “Subscribe” button and you’ll be notified when something actually happens.

@o15a3d4l11s2
Copy link

@friedbunny I believe there a a lot of people interested in clustering support. Could you please suggest an alternative way for us to express our interest or "vote" for new features?

@friedbunny
Copy link
Contributor

@o15a3d4l11s2 Allow me to humbly suggest GitHub’s emoji “reactions”, which are a positive and unobtrusive way to express interest without cluttering an issue or notifying all of its participants.

@Belzik
Copy link

Belzik commented Feb 9, 2018

Hi, can you please tell me how can I cluster the points with different pictures (icons)? (ios)

@stale
Copy link

stale bot commented Oct 28, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the archived Archived because of inactivity label Oct 28, 2018
@mourner mourner removed the archived Archived because of inactivity label Oct 29, 2018
@mourner
Copy link
Member

mourner commented Oct 29, 2018

Keeping this open since it's a highly requested feature and we still intend to address this at some point.

@magnuspaaske
Copy link

Is there any news on this? It would be highly beneficial to be able to cluster annotations without resorting to geojson.

@aquabay
Copy link

aquabay commented Jan 24, 2019

After 2.5 years since this issue was raised. Any progress/alternatives?

@vegidio
Copy link

vegidio commented Jan 24, 2019

Wow, 2.5 years indeed. I've completely forgotten that this still existed.

@aquabay Anyway, I moved away from Mapbox long ago and I found an easy way to do clustering using the good-old Google Maps:

Good luck!

@aquabay
Copy link

aquabay commented Jan 24, 2019

Wow, 2.5 years indeed. I've completely forgotten that this still existed.

@aquabay Anyway, I moved away from Mapbox long ago and I found an easy way to do clustering using the good-old Google Maps:

Good luck!

That's fine if your app is making a bucket load of profit or has minimal traffic (no pun intended). Google Maps now have their hand well and truly in your pocket. I'm not sure their pricing schedule has anything to do with luck ;)

https://cloud.google.com/maps-platform/pricing/sheet

@mapbox mapbox locked and limited conversation to collaborators Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android clustering Core The cross-platform C++ core, aka mbgl Google Maps parity For feature parity with the Google Maps SDK for Android or iOS MapKit parity For feature parity with MapKit on iOS or macOS
Projects
None yet
Development

No branches or pull requests