ThinkGeo.com    |     Documentation    |     Premium Support

Show labels for circles

Hi,



I am creating venn diagram using mapsuite.



I created some circles and i want to show labels on respective areas(intersections etc.)



but labels are not visible



i created below code



private void CreateVenn()
        {
            map.MapUnit = GeographyUnit.DecimalDegree;
            map.CurrentExtent = new RectangleShape(0, 100, 100, 0);
            map.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);






            LayerOverlay inMemoryFeatureOverlay = new LayerOverlay();
            inMemoryFeatureOverlay.TileType = TileType.SingleTile;
            inMemoryFeatureOverlay.Layers.Add("InMemoryFeatureLayer1", GetLayer(20, 20, 30, GeoColor.StandardColors.RoyalBlue));
            inMemoryFeatureOverlay.Layers.Add("InMemoryFeatureLayer2", GetLayer(50, 30, 15, GeoColor.StandardColors.Red));
            inMemoryFeatureOverlay.Layers.Add("InMemoryFeatureLayer3", GetLayer(40, 50, 20, GeoColor.StandardColors.Green));



            var res = new Feature(new EllipseShape(new PointShape(20, 20), 30)).GetIntersection(new Feature(new EllipseShape(new PointShape(50, 30), 15))).GetDifference(new Feature(new EllipseShape(new PointShape(40, 50), 20)));
            res.ColumnValues.Add("Name", "25");
            inMemoryFeatureOverlay.Layers.Add("InMemoryFeatureLayer4", GetLayer(res, GeoColor.StandardColors.Black));
            map.Overlays.Add("InMemoryOverlay", inMemoryFeatureOverlay);
            map.Refresh();
        }






        public InMemoryFeatureLayer GetLayer(int centerX, int centerY, int radius, GeoColor color)
        {
            InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
            inMemoryLayer.InternalFeatures.Add("Circle", new Feature(new EllipseShape(new PointShape(centerX, centerY), radius)));



            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, color);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("Name");
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            return inMemoryLayer;
        }



        public InMemoryFeatureLayer GetLayer(Feature feature, GeoColor color)
        {
            InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
            inMemoryLayer.InternalFeatures.Add("Circle", feature);



            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, color);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Country1("Name");
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            return inMemoryLayer;
        }




thanks.

Hi Laliya, 
  
 Based on those codes, I can guess the label didn’t show is because the columns are missing in both InMemoryFeatureLayer and the added feature, please following the below codes: 
  
  
public InMemoryFeatureLayer GetLayer(int centerX, int centerY, int radius, GeoColor color)
{
      InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
      inMemoryLayer.Open();
      inMemoryLayer.Columns.Add(new FeatureSourceColumn("Name"));
      inMemoryLayer.Close();
      Feature feature = new Feature(new EllipseShape(new PointShape(centerX, centerY), radius));
      feature.ColumnValues.Add("Name", "Circle" + count.ToString());
      inMemoryLayer.InternalFeatures.Add(feature.Id, feature);
      inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, color);
      inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
      inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1("Name");
      inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
      inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
      inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
      count++;
      return inMemoryLayer;
}
 
  
 Hope it helps. 
 Thanks, 
 Johnny

Hi Johnny,

That worked!!



Thanks a lot.

Hi Lalitya, 
  
 You are welcome. 
 Don’t hesitate to let us know if there is any question. 
  
 Thanks, 
 Johnny