Don,
Thanks for the scale calculation. However, I have been attempting to use it during printing and not getting the results I want. My base map is in projection 3857 with meter MapUnit. When I build my print layer I am using the following:
mapPrinterLayer.SetPosition(42,32, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y, PrintingUnit.Inch);
var currentExtent = ExtentHelper.GetDrawingExtent(MapkitMap.CurrentExtent, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);//MapkitMap.CurrentExtent;
mapPrinterLayer.MapExtent = currentExtent;
mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 1));
double mile = 1.0;
double inchInMile = Conversion.ConvertMeasureUnits(2, DistanceUnit.Inch, DistanceUnit.Mile);
var scale = mile/inchInMile;
mapPrinterLayer.MapExtent = ExtentHelper.ZoomToScale(scale, mapPrinterLayer.MapExtent, mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);
This appears to set the scale correctly and my scale bar will read 1 inch = 2640 Feet. However, when I then send this to the printer and use a ruler to measure 1 mile, I find that each mile is printed at a 3 inch scale, not the 2 inch scale I thought was set. Does this have anything to do with the projection I am using or the map units? I know there was an issue with GetLength functions and you introduced a GetAccurateLength to help with.
In the end, what I am looking for is how to set my scale so when I print, the scale bar that you provide is accurate.
ScaleTextPrinterLayer scaleBar = new ScaleTextPrinterLayer(PrintingUnit.Inch, DistanceUnit.Mile, new GeoFont("Arial", 9f),
new GeoSolidBrush(GeoColor.SimpleColors.White), mapPrinterLayer);
scaleBar.BackgroundMask = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Black, 1), new GeoSolidBrush(GeoColor.SimpleColors.White));
scaleBar.WorldUnit = DistanceUnit.Feet;
scaleBar.MapPrinterLayer = mapPrinterLayer;
scaleBar.TextBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black);
scaleBar.SetPosition(1.5, .25, (mapPrinterLayer.GetBoundingBox().LowerLeftPoint.X / 96) + .78, (mapPrinterLayer.GetBoundingBox().LowerLeftPoint.Y / 96) + .25, PrintingUnit.Inch);
scaleBar.PrinterWrapMode = PrinterWrapMode.WrapText;
printerInteractiveOverlay.PrinterLayers.Add("ScaleBar", scaleBar);