I think I solved it.
First of all, I added a geodesic option, so the user can choose if he wantss the geodesic measures or not.
Second, I created this function (based on the ScaleLine):
getGeodesicRatio: function() {
var res = this.map.getResolution();
if (!res) {
return;
}
var curMapUnits = this.map.getUnits();
var inches = OpenLayers.INCHES_PER_UNIT;
// convert maxWidth to map units
var maxSizeData = this.maxWidth * res * inches[curMapUnits];
var geodesicRatio = 1;
if(this.geodesic) {
var maxSizeGeodesic = (this.map.getGeodesicPixelSize().w ||
0.000001) * this.maxWidth;
var maxSizeKilometers = maxSizeData / inches["km"];
geodesicRatio = maxSizeGeodesic / maxSizeKilometers;
}
return geodesicRatio;
},
Third, I inserted the geodesic ratio in other functions:
"getComp"
var ppdu = OpenLayers.DOTS_PER_INCH * system.inches[unitIndex]
/ this.getGeodesicRatio() / this.scale;
"setSubPros"
var ppdu = OpenLayers.DOTS_PER_INCH * system.inches[unitIndex]
/ this.getGeodesicRatio() / this.scale;
I hope this is useful.