This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity : AppCompatActivity, IOnMapReadyCallback, ClusterManager.IOnClusterItemInfoWindowClickListener | |
{ | |
private ClusterRenderer m_ClusterRenderer; | |
//... | |
public void OnMapReady(GoogleMap map) | |
{ | |
m_map = map; | |
//Initialize cluster manager. Setting the CameraIdleListener is mandatory | |
m_ClusterManager = new ClusterManager(this, m_map); | |
m_map.SetOnCameraIdleListener(m_ClusterManager); | |
//Initialize cluster renderer, and keep a reference that will be usefull for the info window's click event | |
m_ClusterRenderer = new ClusterRenderer(this, m_map, m_ClusterManager); | |
m_ClusterManager.Renderer = m_ClusterRenderer; | |
//Custom info window : single markers only (a click on a cluster marker should not show info window) | |
m_ClusterManager.MarkerCollection.SetOnInfoWindowAdapter(new CustomGoogleMapInfoWindow(this)); | |
m_map.SetInfoWindowAdapter(m_ClusterManager.MarkerManager); | |
//Handle Info Window's click event | |
m_map.SetOnInfoWindowClickListener(m_ClusterManager); | |
m_ClusterManager.SetOnClusterItemInfoWindowClickListener(this); | |
SetupMap(); | |
} | |
public void OnClusterItemInfoWindowClick(Java.Lang.Object p0) | |
{ | |
//You can retrieve the ClusterItem clicked with a cast | |
ClusterItem itemClicked = (ClusterItem)p0; | |
Toast.MakeText(this, "Info Window clicked !", ToastLength.Short).Show(); | |
//Dismiss the info window clicked | |
m_ClusterRenderer.GetMarker(itemClicked).HideInfoWindow(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment