[MOD-2426] Ti.Map: Android - Marker Clustering
| GitHub Issue | n/a | 
|---|---|
| Type | New Feature | 
| Priority | Low | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2018-05-29T15:28:11.000+0000 | 
| Affected Version/s | n/a | 
| Fix Version/s | Release 7.4.0 | 
| Components | Map | 
| Labels | android, clustering, feature, maps, mapview, ti.map | 
| Reporter | Ralf Pfeiffer | 
| Assignee | Hans Knöchel | 
| Created | 2011-04-15T03:30:17.000+0000 | 
| Updated | 2018-08-06T17:57:53.000+0000 | 
Description
	Ti needs a way to easily cluster markers within the native MapView used in [Ti.Map](https://github.com/appcelerator-modules/ti.map).
This is a commonly used feature in Map. Please include it for iOS and Android
+1
There is an experimental support for iOS clustering using Google Maps available [here](https://github.com/hansemannn/Ti.GoogleMaps/tree/clustering). For Ti.Map: - iOS: As far as I know, MapKit (which is used by ti.map iOS) does not have an API for clustering, there are only 3rd-party solutions / algorithms available. - Android: There is an [API](https://developers.google.com/maps/documentation/android-api/utility/marker-clustering?hl=en) by Google Maps (which is used by ti.map Android) that could be implemented. If someone from the community is interesting in contributing this functionality, feel free to create a pull request!
Update on this feature: I just implemented a proof of concept of iOS MKMapKit annotation clustering. It uses the native FBAnnotationClustering library to group the annotations. The result can be found here: https://github.com/hansemannn/ti.map/tree/Clustering. Note: This feature is still very experimental, I tested it using 10000 annotations using this demo:
var map = require("ti.map"); var mapView = map.createView({ clusterCellSizeFactor: 0.5, clusterTintColor: "red" clusterTextColor: "white" }); var annotations = []; for(var i = 0; i < 10000;i++) { annotations.push(map.createAnnotation({ latitude: 52.695348 +i, longitude: 7.299401 + Math.sin(i), title: "Annotation" })); } mapView.setAnnotations(annotations); mapView.cluster(); var window = Ti.UI.createWindow(); window.add(mapView); window.open();Added some more functionality and docs, so everyone who already needs the functionality can grab it from this PR: https://github.com/appcelerator-modules/ti.map/pull/149
I tried your cluster branch, but on mapView.cluster(), all pins are gone and no cluster marker appear.
Interesting, can you provide a demo to reproduce? Also, are you using custom pins and/or overlays? Early tests have only been done with "native" pins.
Side note: Stable clustering is also available in [Ti.GoogleMaps](https://github.com/hansemannn/ti.googlemaps/) for the ones interested!
iOS 11 finally supports native clustering! This could be considered for Ti.Map on both iOS and Android by now.
Started a fork for Ti.Map Android at https://github.com/m1ga/ti.map/tree/cluster The click-events are not working (infobox) but the clustering is handled by
android-maps-utils-release.aarThe iOS-part is now merged and part of Ti.Map iOS 3.0.0. Android will likely follow once the review-comments are cleared.
PR (community, thanks to [~michael]): https://github.com/appcelerator-modules/ti.map/pull/215
All PR's merged. New release available: https://github.com/appcelerator-modules/ti.map/releases/tag/android-4.3.0
Cleaning up older fixed tickets from 2016 and earlier. If this ticket should not have been closed, please reopen it.