private void clusterGeocaches(bool recluster) { List <MapControl.Marker> mlist = new List <MapControl.Marker>(); if (!radioButtonActive.Checked) { double lat1 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(0, this.mapContainerControl1.MapCanvas.Zoom); double lat2 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(1, this.mapContainerControl1.MapCanvas.Zoom); double deltaLat = 200 * (lat1 - lat2) / 256.0; //200px double lon1 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(0, this.mapContainerControl1.MapCanvas.Zoom); double lon2 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(1, this.mapContainerControl1.MapCanvas.Zoom); double deltaLon = 200 * (lon2 - lon1) / 256.0; //200px if (_clusterGeocaches == null || recluster) { _clusterGeocaches = new MapControl.MarkerClusterer(deltaLat, deltaLon); bool addAll = radioButtonAll.Checked; bool doCluster = this.mapContainerControl1.MapCanvas.Zoom < 12; foreach (Framework.Data.Geocache gc in _core.Geocaches) { if (gc != _core.ActiveGeocache && (addAll || gc.Selected)) { _clusterGeocaches.AddMarker(gc, doCluster); } } } //add markers foreach (var b in _clusterGeocaches.Buckets) { MapControl.Marker m = new MapControl.Marker(); m.Latitude = b.Latitude; m.Longitude = b.Longitude; if (b.Count == 1) { m.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, b.Geocache.GeocacheType, b.Geocache.ContainsCustomLatLon); m.Tag = b.Geocache; } else { m.ImagePath = ""; m.Tag = b.Count; } mlist.Add(m); } } this.mapContainerControl1.SetGeocacheMarkers(mlist); }
private void clusterGeocaches(bool recluster) { List<MapControl.Marker> mlist = new List<MapControl.Marker>(); if (!radioButtonActive.Checked) { double lat1 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(0, this.mapContainerControl1.MapCanvas.Zoom); double lat2 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(1, this.mapContainerControl1.MapCanvas.Zoom); double deltaLat = 200 * (lat1 - lat2) / 256.0; //200px double lon1 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(0, this.mapContainerControl1.MapCanvas.Zoom); double lon2 = this.mapContainerControl1.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(1, this.mapContainerControl1.MapCanvas.Zoom); double deltaLon = 200 * (lon2 - lon1) / 256.0; //200px if (_clusterGeocaches == null || recluster) { _clusterGeocaches = new MapControl.MarkerClusterer(deltaLat, deltaLon); bool addAll = radioButtonAll.Checked; bool doCluster = this.mapContainerControl1.MapCanvas.Zoom<12; foreach (Framework.Data.Geocache gc in _core.Geocaches) { if (gc != _core.ActiveGeocache && (addAll || gc.Selected)) { _clusterGeocaches.AddMarker(gc, doCluster); } } } //add markers foreach (var b in _clusterGeocaches.Buckets) { MapControl.Marker m = new MapControl.Marker(); m.Latitude = b.Latitude; m.Longitude = b.Longitude; if (b.Count == 1) { m.ImagePath = Utils.ImageSupport.Instance.GetImagePath(_core, Framework.Data.ImageSize.Map, b.Geocache.GeocacheType, b.Geocache.ContainsCustomLatLon); m.Tag = b.Geocache; } else { m.ImagePath = ""; m.Tag = b.Count; } mlist.Add(m); } } this.mapContainerControl1.SetGeocacheMarkers(mlist); }