Fix ScaleLine control for Projections in degrees
This commit is contained in:
@@ -176,7 +176,7 @@ ScaleLine.prototype.updateElement_ = function() {
|
|||||||
Units.METERS;
|
Units.METERS;
|
||||||
let pointResolution =
|
let pointResolution =
|
||||||
getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
|
getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
|
||||||
if (units != ScaleLineUnits.DEGREES) {
|
if (projection.getUnits() != Units.DEGREES && units == ScaleLineUnits.METRIC) {
|
||||||
pointResolution *= projection.getMetersPerUnit();
|
pointResolution *= projection.getMetersPerUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,6 +298,21 @@ describe('ol.control.ScaleLine', function() {
|
|||||||
map.renderSync();
|
map.renderSync();
|
||||||
expect(ctrl.element_.innerText).to.be('100 mm');
|
expect(ctrl.element_.innerText).to.be('100 mm');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Metric display works with Geographic (EPSG:4326) projection', function() {
|
||||||
|
var ctrl = new ScaleLine();
|
||||||
|
ctrl.setMap(map);
|
||||||
|
map.setView(new View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 0, /* min zoom */
|
||||||
|
projection: 'EPSG:4326'
|
||||||
|
}));
|
||||||
|
map.renderSync();
|
||||||
|
expect(ctrl.element_.innerText).to.be('10000 km');
|
||||||
|
map.getView().setZoom(28); /* max zoom */
|
||||||
|
map.renderSync();
|
||||||
|
expect(ctrl.element_.innerText).to.be('50 mm');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('latitude may affect scale line in EPSG:4326', function() {
|
describe('latitude may affect scale line in EPSG:4326', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user