<a href="http://trac.openlayers.org/ticket/1890" title="Scale and ScaleLine in Google approx double correct figure at some resolutions">OpenLayers Ticket #1890</a> (link now dead) - Scale & ScaleLine Controls giving incorrect scales.
The Scale control prints the 1 : X
scale factor. The
ScaleLine control draws the scale measure that we are used to seeing in the legend for printed maps.
The apparent problem of them both giving incorrect scales occurs in Spherical Mercator projections
such as that used by Google Maps.
The controls have actually been fixed, but by default will still give incorrect scales. To get
them to display correctly, an extra parameter {geodesic:true}
is
required. With the ScaleLine control, this is trivially obvious how to do, but with the Scale
control things are a little more obscure, because the options parameter to the constructor is the
second parameter, not the first, so what should be given as the first parameter? See below for
how to get round this. The manner of having to declare the control to get it to
work is unfortunate, but at least it does now work.
The map on the left has the correct scale value (green).
The map on the right declares the Scale control as:
new OpenLayers.Control.Scale()
and thus it gives incorrect values (red).
Attempting to fix it, the map on the left breaks the Scale control by declaring it as:
new OpenLayers.Control.Scale( {geodesic:true} )
.
Successfully fixing it, The map on the right declares the working Scale control as:
new OpenLayers.Control.Scale( undefined, {geodesic:true} )
.
This demo uses the live APIs - OpenLayers API and Google Maps API .