private void DisplayMap_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); InMemoryFeatureLayer pointLayers = new InMemoryFeatureLayer(); pointLayers.Open(); pointLayers.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1; pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new MyTextStyle("text", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black)); pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping; pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.PointPlacement = PointPlacement.UpperRight; pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.Mask = AreaStyles.Country1; pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.XOffsetInPixel = 15; pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.YOffsetInPixel = 15; pointLayers.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.MaskMargin = 2; pointLayers.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; pointLayers.Columns.Add(new FeatureSourceColumn("text")); Feature feature1 = new Feature(0, 0); Feature feature2 = new Feature(1, 0); feature1.ColumnValues.Add("text", "dfadfefdfefdfefdfe"); feature2.ColumnValues.Add("text", "222fadfefdfefdfefdfe"); pointLayers.InternalFeatures.Add(feature1); pointLayers.InternalFeatures.Add(feature2); LayerOverlay statesOverlay = new LayerOverlay(); statesOverlay.Layers.Add("MajorCitiesShapes", pointLayers); winformsMap1.Overlays.Add("StatesOverlay", statesOverlay); winformsMap1.CurrentExtent = new RectangleShape(-20, 20, 20, -20); winformsMap1.Refresh(); } class MyTextStyle : TextStyle { public MyTextStyle(string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush) : base(textColumnName, textFont, textSolidBrush) { } protected override void DrawCore(System.Collections.Generic.IEnumerable features, GeoCanvas canvas, System.Collections.ObjectModel.Collection labelsInThisLayer, System.Collections.ObjectModel.Collection labelsInAllLayers) { base.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers); LineStyle style = new LineStyle(new GeoPen(GeoColor.SimpleColors.Red)); PointShape upperRightPoint = null; int counter = 0; foreach (Feature feature in features) { upperRightPoint = feature.GetBoundingBox().UpperRightPoint; LineShape line = new LineShape(); line.Vertices.Add(new Vertex(upperRightPoint)); PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, (float)a[counter].ScreenArea.OuterRing.GetBoundingBox().UpperRightPoint.X, (float)a[counter].ScreenArea.OuterRing.GetBoundingBox().UpperRightPoint.Y, canvas.Width, canvas.Height); line.Vertices.Add(new Vertex(lowerRightPoint)); style.Draw(new Collection() { line }, canvas, new Collection(), new Collection()); counter++; } a.Clear(); } Collection a = new Collection(); protected override bool CheckOverlappingCore(LabelingCandidate labelingCandidate, GeoCanvas canvas, System.Collections.ObjectModel.Collection labelsInThisLayer, System.Collections.ObjectModel.Collection labelsInAllLayers) { while (base.CheckOverlappingCore(labelingCandidate, canvas, labelsInThisLayer, labelsInAllLayers)) { labelingCandidate.CenterPoint.Y -= 2; labelingCandidate.ScreenArea.TranslateByOffset(0, -2); } a.Add(labelingCandidate); return false; } }