public class MainActivity : AppCompatActivity, IOnMapReadyCallback | |
{ | |
private ClusterManager m_ClusterManager; | |
//... | |
public void OnMapReady(GoogleMap map) | |
{ | |
m_map = map; | |
//Initialise cluster manager. Setting the CameraIdleListener is mandatory | |
m_ClusterManager = new ClusterManager(this, m_map); | |
m_map.SetOnCameraIdleListener(m_ClusterManager); | |
SetupMap(); | |
} | |
private void SetupMap() | |
{ | |
//Show Grenoble on the map | |
LatLng LatLonGrenoble = new LatLng(45.188529, 5.724523); | |
m_map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(LatLonGrenoble, Resources.GetInteger(Resource.Integer.default_zoom_level_googlemaps))); | |
List<ClusterItem> lsMarkers = new List<ClusterItem>(); | |
//Add 50 markers using a spiral algorithm (cheers SushiHangover) | |
for (int i = 0; i < 50; ++i) | |
{ | |
double theta = i * Math.PI * 0.33f; | |
double radius = 0.005 * Math.Exp(0.1 * theta); | |
double x = radius * Math.Cos(theta); | |
double y = radius * Math.Sin(theta); | |
ClusterItem newMarker = new ClusterItem(LatLonGrenoble.Latitude + x, LatLonGrenoble.Longitude + y); | |
lsMarkers.Add(newMarker); | |
} | |
//Add markers to the map through the cluster manager | |
m_ClusterManager.AddItems(lsMarkers); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment