ThinkGeo.com    |     Documentation    |     Premium Support

Creating a label that included a bit map and text


In the 2.x version I could create a label using both a bitmap and text. As seen above. In the 3.x version I have not figured out how to do the same thing.


In ver 2.x this is the code I used.



    Private Function GetHighwayLabelStyle() As GeoTextStyle
        Dim textStyle As New GeoTextStyle()
        Dim TextSymbols As New TextSymbolCollection()

        Dim font As New GeoFont("Arial", 7, GeoFontStyle.Bold)
        Dim brush As New GeoSolidBrush(GeoColor.KnownColors.White)
        Dim symbol As New TextSymbol(font, brush, 0, -6)
        TextSymbols.Add(symbol)

        Dim Icon As New IconRenderer(StreetFieldName, TextSymbols, IconHighwayShield)

        textStyle.LabelRenderers.Add(Icon)
        Return textStyle
    End Function


I figured it out... even easier than before



 Private Function GetInterstateIconStyle(ByVal FieldName As String, Optional ByVal FontSize As Integer = 12, Optional ByVal FontName As String = "Arial") As IconStyle

        Dim IC As New IconStyle(IconHWYShield, FieldName, New GeoFont(FontName, 10, DrawingFontStyles.Bold), New GeoSolidBrush(GeoColor.StandardColors.White))

        IC.TextLineSegmentRatio = 50

        Return IC

    End Function


Not sure if you picked it up, but you have a parameter for Optional FontSize = 12 but you have hard coded font size as 10 in your GeoFont.



Michael, 
  
   You have quite the eagle eye for code, nice catch.  Do you mind if I send you a few thousand lines of source to see if you spot any issue? :-) Only kidding of course.  Thanks a bunch for sharing. 
  
 David



Thanks for catching that. 

I posted it right after I figured out how to make it work... 



I was waiting for someone to catch the "IC.TextLineSegmentRatio = 50", because without it it almost never places any labels at all. 





Alan



Alan, 



TextLineSegmentRatio property allows you to suppress labels where the label length would greatly exceed the line length. For example, if you set the ratio to 1, then the label will be suppressed if it is longer than the line. If the ratio is lower than 1, then it would need to be shorter than the line.




Thanks, 

ThinkGeo Support 

 



Lee, 
  
 I think the problem here is that it looks at line "segments" and not the entire line. 
  
 For a local road that runs a straight line and only includes two points (or just a few points) the distance between the points would be relatively long.  
  
 But for roads that have many curves and many segments (and points) the length of each segment is small. So even a raod that all the way around the map it may still not place a label.  
  
 And that is exactly what I am seeing. 
  
 With a map where there is an Interstate Hwy running from one corner to the other the following renders 0 labels 
  
        TextLineSegmentRatio = 0.9 
        GridSize = 1 
        OverlappingRule = LabelOverlappingRule.AllowOverlapping 
        SuppressPartialLabels = False 
        DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels 
  
 The following seems to work very well for both roads with long segments and short segments 
  
        TextLineSegmentRatio = 500 
        GridSize = 1 
        OverlappingRule = LabelOverlappingRule.NoOverlapping 
        SuppressPartialLabels = True 
        DuplicateRule = LabelDuplicateRule.OneDuplicateLabelPerQuadrant 
  
 Essentially I think that setting the TextLineSegmentRatio to 500 or greater disables it. 
  
 Alan

Alan, 
  
 This is what we are going to do next. Currently this property calculates the distance between two points and compares it with the label length. If the road is made up of many points which are very closely and it is almost a straight line, this property may not work well unless you set it to 500 or greater. We have added it to our tracking system. For now you can set some large number to this property to make your application work. 
  
 Also there is another property SplineType which allows to label around the curved lines. This may have a considerable performance impact, so we suggest you experiment with it to ensure it can meet your needs first. This property is available in the next version which will be release around early next month, please mail to support@thinkgeo.com to get a temporary assembly if you want it before the release. 
  
 Thanks, 
 ThinkGeo Support