ScaleLinePrinterLayer does not match ScaleBarPrinterLayer

I recently compared the scales/lengths of a ScaleLinePrinterLayer with a ScaleBarPrinterLayer as part of the print preview system. The scales reported do not match between the two. I am using TG v14.5.4 and we are getting ready to deploy to our clients. Can you tell me which of the two is correct? [Edit: It appears that the ScaleBarPrinterLayer is correct.]Then we can recommend that our users use the correct one. If there is a workaround that would be great. I have attached a sample project. Also, I am using a 4k monitor set at 150% magnification in case that’s part of the problem.

Incidentally, this does not appear to be a problem in 15 beta.

Thanks!

Steve
SetPositionDemo.zip (326.5 KB)

Hi Steve,

Thanks for the sample project - you’re right, ScaleBarPrinterLayer is the correct one.

It was a known issue that ScaleLinePrinterLayer not working correctly with the ScaleFactor other than 100%, and it was fixed in beta branch last month. You can either wait for v15 (by early next month), or you can try the following workaround in your current version:

Imports System.Collections.ObjectModel
Imports ThinkGeo.Core

Public Class FixedScaleLinePrinterLayer
    Inherits ScaleLinePrinterLayer

    Public Sub New(mapPrinterLayer As MapPrinterLayer)
        MyBase.New(mapPrinterLayer)
    End Sub

    Protected Overrides Sub DrawCore(canvas As GeoCanvas, labelsInAllLayers As Collection(Of SimpleCandidate))
        Dim scaleFactor As Single = canvas.ScaleFactor
        canvas.ScaleFactor = 1
        Try
            MyBase.DrawCore(canvas, labelsInAllLayers)
        Finally
            canvas.ScaleFactor = scaleFactor
        End Try
    End Sub
End Class

In your AddScaleLineLayer:

Dim oScaleLineLayer As New FixedScaleLinePrinterLayer(moMapPrinterLayer)

Don’t forget to remove it after upgrading to v15.

Thanks,
Ben

Ben,

Thanks, the workaround works pefectly.

Steve

That’s awesome! :+1: