I have a map with projection: 'EPSG:4326'. In v4.5.0, ol.control.ScaleLine seems to work. this codepen with v4.5.0 shows the initial value of the scale line = 5,000 km. At maximal zoom, I see the scale line reports 50mm ~(although this seems to be reported at max zoom regardless of latitude)~.
A fork of that codepen using v4.6.0 shows the initial value of the scale line = 500,000,000km. At maximal zoom, I see the scale line reports 5km (regardless of latitude). I also see the same behavior when using v4.6.4.
v4.6.4 seems to work as expected if I comment out these lines from #7462:
if (units != ol.control.ScaleLineUnits.DEGREES) {
pointResolution *= projection.getMetersPerUnit();
}
A little history I found:
projection: 'EPSG:4326' (aka this issue)Should the conditional on src/ol/control/ScaleLine.js#180 be more complex, something like the following?
if (projection.units == ol.proj.Units.METERS && units == ol.control.ScaleLineUnits.METRIC) {
pointResolution *= projection.getMetersPerUnit();
}
Such a change would make sense to me. Can you create a pull request please?
For people wanting to fix this in v4.6.5 you can't follow this PR. Unfortunatly its for v5.* so you can't just copy paste it.
This should replace the condition used on line 180 in scaleline.js
The exact fix is :
```js
if (projection.getUnits() != _ol_control_ScaleLineUnits_.DEGREES &&
units == ol_control_ScaleLineUnits_.METRIC)
pointResolution *= projection.getMetersPerUnit();
Most helpful comment
Such a change would make sense to me. Can you create a pull request please?