protected void Page_Load(object sender, EventArgs e) { GMap1.Add(new GMapUI()); GMap1.GZoom = 2; GMap2.Add(new GMapUI()); GMap2.GZoom = 2; List <GMarker> markers = new List <GMarker>(); Random r = new Random(); for (int i = 0; i < 200; i++) { GMarker gMarker = new GMarker(new GLatLng(r.Next(0, 60), r.Next(-30, 30))); markers.Add(gMarker); GListener listener = new GListener(gMarker.ID, GListener.Event.click, string.Format(@"function () {{ var w = new google.maps.InfoWindow(); w.setContent('<center>{0}</center>'); w.open({1}, {2});}}", i, GMap1.GMap_Id, gMarker.ID)); GMap1.Add(listener); } GMap2.markerClusterer = new MarkerClusterer(markers); MarkerClustererStyleOptions markerClustererStyleOptions = new MarkerClustererStyleOptions(); markerClustererStyleOptions.textColor = Color.Yellow; MarkerClustererOptions markerClustererOptions = new MarkerClustererOptions(60, 10); MarkerClustererStyleOptions styleOptionsA = new MarkerClustererStyleOptions(); styleOptionsA.height = 36; styleOptionsA.width = 40; styleOptionsA.anchor_x = 6; styleOptionsA.anchor_y = 0; styleOptionsA.textColor = Color.Blue; styleOptionsA.url = "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/conv40.png"; MarkerClustererStyleOptions styleOptionsB = new MarkerClustererStyleOptions(); styleOptionsB.height = 35; styleOptionsB.width = 35; styleOptionsB.anchor_x = 16; styleOptionsB.anchor_y = 0; styleOptionsB.textColor = Color.WhiteSmoke; styleOptionsB.url = "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/people35.png"; markerClustererOptions.markerClustererStylesOptions.Add(styleOptionsA); markerClustererOptions.markerClustererStylesOptions.Add(styleOptionsB); MarkerClusterer markerClusterer = new MarkerClusterer(markers, markerClustererOptions); GMap1.markerClusterer = markerClusterer; }
protected void Page_Load(object sender, EventArgs e) { GMap1.Add(new GMapUI()); GMap1.GZoom = 2; GMap2.Add(new GMapUI()); GMap2.GZoom = 2; List<GMarker> markers = new List<GMarker>(); Random r = new Random(); for (int i = 0; i < 200; i++) { GMarker gMarker = new GMarker(new GLatLng(r.Next(0, 60), r.Next(-30, 30))); markers.Add(gMarker); GListener listener = new GListener(gMarker.ID, GListener.Event.click, string.Format(@"function () {{ var w = new google.maps.InfoWindow(); w.setContent('<center>{0}</center>'); w.open({1}, {2});}}", i, GMap1.GMap_Id, gMarker.ID)); GMap1.Add(listener); } GMap2.markerClusterer = new MarkerClusterer(markers); MarkerClustererStyleOptions markerClustererStyleOptions = new MarkerClustererStyleOptions(); markerClustererStyleOptions.textColor = Color.Yellow; MarkerClustererOptions markerClustererOptions = new MarkerClustererOptions(60, 10); MarkerClustererStyleOptions styleOptionsA = new MarkerClustererStyleOptions(); styleOptionsA.height = 36; styleOptionsA.width = 40; styleOptionsA.anchor_x = 6; styleOptionsA.anchor_y = 0; styleOptionsA.textColor = Color.Blue; styleOptionsA.url = "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/conv40.png"; MarkerClustererStyleOptions styleOptionsB = new MarkerClustererStyleOptions(); styleOptionsB.height = 35; styleOptionsB.width = 35; styleOptionsB.anchor_x = 16; styleOptionsB.anchor_y = 0; styleOptionsB.textColor = Color.WhiteSmoke; styleOptionsB.url = "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/people35.png"; markerClustererOptions.markerClustererStylesOptions.Add(styleOptionsA); markerClustererOptions.markerClustererStylesOptions.Add(styleOptionsB); MarkerClusterer markerClusterer = new MarkerClusterer(markers, markerClustererOptions); GMap1.markerClusterer = markerClusterer; }
private void clusterGeocaches(bool recluster) { List <Marker> mlist = new List <Marker>(); if (Core.ApplicationData.Instance.ActiveDatabase != null && TargetGeocaches != GeocachesOnMap.Active) { double lat1 = this.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(0, this.tileCanvas.Zoom); double lat2 = this.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(1, this.tileCanvas.Zoom); double deltaLat = 200 * (lat1 - lat2) / 256.0; //200px double lon1 = this.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(0, this.tileCanvas.Zoom); double lon2 = this.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(1, this.tileCanvas.Zoom); double deltaLon = 200 * (lon2 - lon1) / 256.0; //200px if (_clusterGeocaches == null || recluster) { _clusterGeocaches = new MarkerClusterer(deltaLat, deltaLon); bool addAll = TargetGeocaches == GeocachesOnMap.All; bool doCluster = this.tileCanvas.Zoom < 12; foreach (var gc in Core.ApplicationData.Instance.ActiveDatabase.GeocacheCollection) { if (gc != Core.ApplicationData.Instance.ActiveGeocache && (addAll || gc.Selected)) { _clusterGeocaches.AddMarker(gc, doCluster); } } } //add markers foreach (var b in _clusterGeocaches.Buckets) { Marker m = new Marker(); m.Latitude = b.Latitude; m.Longitude = b.Longitude; if (b.Count == 1) { m.ImagePath = string.Format("/resources/CacheTypes/Map/{0}.png", b.Geocache.GeocacheType.ID); m.Tag = b.Geocache; } else { m.ImagePath = ""; m.Tag = b.Count; } mlist.Add(m); } } this.SetGeocacheMarkers(mlist); }
private void clusterGeocaches(bool recluster) { List <Marker> mlist = new List <Marker>(); if (_gcList != null) { double lat1 = this.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(0, this.tileCanvas.Zoom); double lat2 = this.tileCanvas.MapControlFactory.TileGenerator.GetLatitude(1, this.tileCanvas.Zoom); double deltaLat = 200 * (lat1 - lat2) / 256.0; //200px double lon1 = this.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(0, this.tileCanvas.Zoom); double lon2 = this.tileCanvas.MapControlFactory.TileGenerator.GetLongitude(1, this.tileCanvas.Zoom); double deltaLon = 200 * (lon2 - lon1) / 256.0; //200px if (_clusterGeocaches == null || recluster) { _clusterGeocaches = new MarkerClusterer(deltaLat, deltaLon); bool doCluster = this.tileCanvas.Zoom < 12; foreach (var gc in _gcList) { _clusterGeocaches.AddMarker(gc, doCluster); } } //add markers foreach (var b in _clusterGeocaches.Buckets) { Marker m = new Marker(); m.Latitude = b.Latitude; m.Longitude = b.Longitude; if (b.Count == 1) { m.ImagePath = string.Format("/Resources/Map/{0}.png", (from a in ApplicationData.Instance.GeocacheTypes where a.GSAK == b.Geocache.CacheType select a.ID).FirstOrDefault()); m.Tag = b.Geocache; } else { m.ImagePath = ""; m.Tag = b.Count; } mlist.Add(m); } } this.SetGeocacheMarkers(mlist); }