ThinkGeo.com    |     Documentation    |     Premium Support

Display three labels in a marker with different color

hello,


 


i want to display 3 labels around one single marker.please see below image for your reference.



For that i have used following code, but I can see the value of  one column1 but cannot see the value of two labels which are column2 and column3.


InMemoryFeatureLayer markerLabelsOverlay = new InMemoryFeatureLayer();

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Column1", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, -25, 15);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Column2", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 25, 10);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Column3", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 25, 5);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.FittingLineInScreen = true;

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.FittingPolygon = true;

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.SplineType = SplineType.StandardSplining;

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.SuppressPartialLabels = true;

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.GridSize = 10;



        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.DrawingLevel = DrawingLevel.LevelOne;





        markerLabelsOverlay.FeatureSource.CustomColumnFetch += new EventHandler<customcolumnfetcheventargs>(MarkerLabels_CustomColumnFetch);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RequiredColumnNames.Add("Column1");        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RequiredColumnNames.Add("Column2");

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RequiredColumnNames.Add("Column3");

        this.DynamicOverlay.Layers.Add("Route Marker Labels", markerLabelsOverlay);</customcolumnfetcheventargs>


 


Can you tell me what should I do for displaying value of remaing two labels? If possible can you provide modified code, this will very helpful to us. also i want to display label in center. 


 


Thanks,


Badal Patel



 


Hi Badal,
For your scenario, I think we should use CustomStyles instead of DefaultStyles. Here as following is the sample about how to use:


InMemoryFeatureLayer markerLabelsOverlay = new InMemoryFeatureLayer();
                markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                TextStyle textStyle1 = TextStyles.CreateSimpleTextStyle("Column1", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, -25, 15);
                textStyle1.OverlappingRule = LabelOverlappingRule.NoOverlapping;
                textStyle1.FittingLineInScreen = true;
                textStyle1.FittingPolygon = true;
                textStyle1.SplineType = SplineType.StandardSplining;
                textStyle1.SuppressPartialLabels = true;
                textStyle1.GridSize = 10;

                TextStyle textStyle2 = TextStyles.CreateSimpleTextStyle("Column2", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 25, 10);
                textStyle2.OverlappingRule = LabelOverlappingRule.NoOverlapping;
                textStyle2.FittingLineInScreen = true;
                textStyle2.FittingPolygon = true;
                textStyle2.SplineType = SplineType.StandardSplining;
                textStyle2.SuppressPartialLabels = true;
                textStyle2.GridSize = 10;

                TextStyle textStyle3 = TextStyles.CreateSimpleTextStyle("Column3", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 25, 5);
                textStyle3.OverlappingRule = LabelOverlappingRule.NoOverlapping;
                textStyle3.FittingLineInScreen = true;
                textStyle3.FittingPolygon = true;
                textStyle3.SplineType = SplineType.StandardSplining;
                textStyle3.SuppressPartialLabels = true;
                textStyle3.GridSize = 10;

                inMemoryLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle1);
                inMemoryLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle2);
                inMemoryLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle3);



Also you can change label position to what we want using the code like below: 
textStyle2.PointPlacement = PointPlacement.Center


Thanks,


Johnny


 



thanx for your reply .


but it is not working. it displays same as previous. there is nothing changes in it. please help me


in my aspx page i write that code.


                Feature labelFeature = new Feature(pnt);

                string vehicleCaption = Convert.ToString(DtMarker.Rows["TagPoint"]);

                labelFeature.ColumnValues.Add("Name", vehicleCaption);

                labelFeature.ColumnValues.Add("TagRead", "Tag Read");

                labelFeature.ColumnValues.Add("Next", Convert.ToString(DtMarker.Rows["NextTagTime"]));

                mainMap.MarkerLabelOverlay.InternalFeatures.Add(labelFeature.Id, labelFeature);


and in map.ascx page i write


 InMemoryFeatureLayer markerLabelsOverlay = new InMemoryFeatureLayer();

        



        TextStyle textStyle1 = TextStyles.CreateSimpleTextStyle("Name", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Green, -25, 15);

        textStyle1.OverlappingRule = LabelOverlappingRule.AllowOverlapping;

        textStyle1.FittingLineInScreen = true;

        textStyle1.FittingPolygon = true;

        textStyle1.SplineType = SplineType.StandardSplining;

       // textStyle1.SuppressPartialLabels = true;

        textStyle1.GridSize = 10;



        TextStyle textStyle2 = TextStyles.CreateSimpleTextStyle("TagRead", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Red, 25, 10);

        textStyle2.OverlappingRule = LabelOverlappingRule.AllowOverlapping;

        textStyle2.FittingLineInScreen = true;

        textStyle2.FittingPolygon = true;

        textStyle2.SplineType = SplineType.StandardSplining;

        //textStyle2.SuppressPartialLabels = true;

        textStyle2.GridSize = 10;



        TextStyle textStyle3 = TextStyles.CreateSimpleTextStyle("Next", "Verdana", 10, DrawingFontStyles.Bold, GeoColor.StandardColors.Blue, 25, 50);

        textStyle3.OverlappingRule = LabelOverlappingRule.AllowOverlapping;

        textStyle3.FittingLineInScreen = true;

        textStyle3.FittingPolygon = true;

        textStyle3.SplineType = SplineType.StandardSplining;

        //textStyle3.SuppressPartialLabels = true;

        textStyle3.GridSize = 10;



        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle1);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle2);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle3);

        markerLabelsOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        markerLabelsOverlay.FeatureSource.CustomColumnFetch += new EventHandler<customcolumnfetcheventargs>(MarkerLabels_CustomColumnFetch);

        this.DynamicOverlay.Layers.Add("Route Marker Labels", markerLabelsOverlay);</customcolumnfetcheventargs>


 


I am sending the screen shot after changing the code given by you.  but the issue is remain same.


 



Badal,


The reason is that the labels overlaps each other, and then it just show the one on the top. Please set the proper XoffsetInPixel , Y offsetInPixel and GridSize to avoid the overlap. Additionaly please set the OverlappingRule to AllowOverlapping, and DuplicateRule to UnlimitedDuplicateLabels. As far as I test, after all the settings, it works.
Thanks,
Johnny