ThinkGeo.com    |     Documentation    |     Premium Support

Clarification of scale value for zoom levels and its relation to the scalebar

Hello, could I get some clarification on how the scaling of the zoom levels work? I understand what the number represents but not how the actual scale value comes to be? What I want to do is, be able to set certain scale levels of actual distance units, so that the scalebar shows those levels/distance units.

For example, I have a bunch of custom zoom levels I add to the map like so:

var partitionedZoomLevelSet = new ZoomLevelSet(); 
partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(myMap.ZoomLevelSet.GetZoomLevels()[0].Scale * 3));
partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(myMap.ZoomLevelSet.GetZoomLevels()[0].Scale * 1.5));
partitionedZoomLevelSet.CustomZoomLevels.Add(new ZoomLevel(myMap.ZoomLevelSet.GetZoomLevels()[0].Scale));
// repeat for a total of 50 zoom levels
myMap.ZoomLevelSet = partitionedZoomLevelSet;

These were arbitrary ones I played around with. But what I want to do is just say something like “at 50 meters on the scale bar is this zoom level, at 10 feet on the scale bar is the next zoom level, etc.”, regardless of the map unit.

Is anything like that possible? I’m using version 13 dlls if that matters

Hi Dan,

Scale is simply the ratio between a distance on your screen and the corresponding distance in the real world. For instance, a scale of 1000 means that 1 inch on your screen represents 1000 inches in reality.

Let’s say you want to create a zoom level where 100 pixels on the screen represent 50 meters on the ground. What scale would that be? Let’s break it down:

  1. Convert pixels to inches:
    100 pixels ≈ 1.04 inches (assuming 96 DPI, because 100 / 96 ≈ 1.04).
  2. Calculate ground distance per inch:
    If 1.04 inches correspond to 50 meters, then 1 inch represents about 50 / 1.04 ≈ 48 meters .
  3. Convert meters to inches:
    Since 1 meter is approximately 39.37 inches, then 48 meters is about 48 × 39.37 ≈ 1890 inches .
    This means one inch on the screen represents about 1890 inches in the real world, giving you a scale of roughly 1:1890 .

Using the ThinkGeo API
If 100 pixels represent 50 meters, the resolution is 0.5 meters per pixel. You can then get the scale like this:

var scale = MapUtil.GetScaleFromResolution(0.5, GeographyUnit.Meter);

Hope that helps! Let me know if you have any questions.

Thanks,
Ben

Thanks Ben! Appreciate the info. So does the scalebar correspond to this scale? Or does it use a different set of values/calculations?

Hi Dan,

If by “scalebar” you meant the panZoomBar as following, yes, it will correspond to the scales you set in the custom ZoomLevelSet. (myMap.ZoomLevelSet = partitionedZoomLevelSet;)
image

Thanks,
Ben

Ah no, sorry. This bar: image

Which is just a ScaleLineAdornmentLayer

Oh, I see.

This scaleline goes with the current map scale. For example, if your current map scale is 1:1890, from our calculation above it means 100 pixels on the screen represent 50 meters on the ground, which means 50 meters mark on the scaleBar will be 100 pixels.

We recently also made some improvements in ScalLine MapTools, check it out if you are interested.
ScaleLineMapTool bug when working with OpenStreetMap - ThinkGeo UI for Desktop - ThinkGeo Discussion Forums

Thanks,
Ben

Got it, thank you for the explanation!

Sure, you are welcome!