If I add over 1k items to the ClusterManager, the actual (drawn) markers are updated after very long delays. For example, I can have one cluster with "1000+" text on it, and when I zoom in, it stays for about 1-2 minutes, and only after that it splits into smaller clusters and markers.
private lateinit var mMap: GoogleMap,
private lateinit var clusterManager: ClusterManager<mapclass>
private fun addItems() {
// welcomedataItemList1=1000
for (place in 0 until welcomedataItemList1.size) {
if (welcomedataItemList1[place]?.lat != null && welcomedataItemList1[place]?.lon != null) {
var latitude =welcomedataItemList1[place].lat.toDouble()
var longitude =welcomedataItemList1[place].lon.toDouble()
serial = welcomedataItemList1[place].serial
ownerName = welcomedataItemList1[place].ownerName
status= welcomedataItemList1[place].adminStatus.toInt()
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(latitude, longitude), 6f))
var offsetItem = mapclass(latitude, longitude, "$serial", "$ownerName")
clusterManager.addItem(offsetItem)
}
}
}
private fun setUpClusterer() {
val metrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(metrics)
clusterManager = ClusterManager(this, mMap)
clusterManager.setAlgorithm(NonHierarchicalViewBasedAlgorithm(metrics.widthPixels, metrics.heightPixels))
mMap.setOnCameraIdleListener(clusterManager)
addItems()
clusterManager.renderer = MarkerClusterRenderer(this, mMap, clusterManager)
mMap.setInfoWindowAdapter(CustomInfoWindowForGoogleMap(this))
mMap.setOnMarkerClickListener(clusterManager)
mMap.uiSettings.isZoomControlsEnabled= true
clusterManager.setAnimation(false);
clusterManager.cluster()
}
override fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap
setUpClusterer()
}
If I add over 1k items to the ClusterManager, the actual (drawn) markers are updated after very long delays. For example, I can have one cluster with "1000+" text on it, and when I zoom in, it stays for about 1-2 minutes, and only after that it splits into smaller clusters and markers.