More than one marker on same place - MarkerClusterer

Viewed 31564

I am using MarkerClusterer. When I have two or more markers on the exact same spot, The API only displays 1 marker - the top one. But somehow I want to show all the markers as each one will be opening distinct popup. I have searched found few solutions but none are seem to be working Anybody had similar issue and would pls share a solution??

4 Answers

MarkerClusterer has option to define maxZoom upto which cluster should be visible in map. You can set its value to 18, so it wont show cluster when user zoomed in to its maximum:

 const markerCluster = new MarkerClusterer(map, markers,{maxZoom: 18});

FYI - Precision

decimal places  decimal degrees N/S or E/W at equator
2   0.01    1.1132 km
3   0.001   111.32 m
4   0.0001  11.132 m
5   0.00001 1.1132 m

Those who are looking out for a solution in ANDROID for the same -

Or if you just want to show a list on clicking on the marker, do the below -

clusterManager.setOnClusterClickListener {
            if (googleMap?.maxZoomLevel == googleMap?.cameraPosition?.zoom) {
                val items = it.items.map { assetItem -> assetItem.title }
                MaterialAlertDialogBuilder(requireContext())
                    .setTitle("Choose an asset")
                    .setItems(items.toTypedArray()) { dialog, which ->
                        dialog.dismiss()
                        onItemClicked(it.items.elementAt(which))
                    }
                    .show()
                return@setOnClusterClickListener true
            }
            return@setOnClusterClickListener false
        }
Related