LabelLayer Font Size vary with Zoom Change

Sep 15, 2015 at 4:35 PM
Hi Team,
Is there any option to vary the font size of LabelLayer with changing the Zoom of Map.


Regards,
Sgoyal.
Sep 16, 2015 at 3:58 AM
Edited Sep 16, 2015 at 3:58 AM
It could be something like the following:

Public Function style_label(ByVal row As SharpMap.Data.FeatureDataRow) As SharpMap.Styles.LabelStyle
Dim s As Single = 16 - (16 * Math.Sqrt(Zoom) / 188) ' Zoom is a variable that must contain the current zoom. 16 would be the maximum size.
if s<1 then s=1
Dim style As New SharpMap.Styles.LabelStyle
style.Font = New Font("Tahoma", s)
Return style
End Function

... and on the layer
Dim layer_theme As New SharpMap.Rendering.Thematics.CustomTheme(AddressOf style_label)
layer.Theme = layer_theme
Sep 17, 2015 at 12:39 PM
Thanks for the reply but what is Zoom variable.
As you said the Maximum zoom value is 16 but when i am capturing the zoom on ZoomChange Event of Mapcontrol it something more than 1000.

Please help us in this.



Regards,
Sgoyal.
Sep 17, 2015 at 3:58 PM
Edited Sep 17, 2015 at 3:59 PM
  • 16 would be the maximum font size.
  • The zoom is dynamic. You can also use MapBox1.Map.Zoom so:

Public Function style_label(ByVal row As SharpMap.Data.FeatureDataRow) As SharpMap.Styles.LabelStyle
Dim s As Single = 16 - (16 * Math.Sqrt(MapBox1.Map.Zoom) / 188)
if s<1 then s=1
Dim style As New SharpMap.Styles.LabelStyle
style.Font = New Font("Tahoma", s)
Return style
End Function

... and on the layer
Dim layer_theme As New SharpMap.Rendering.Thematics.CustomTheme(AddressOf style_label)
layer.Theme = layer_theme