Export render from ol/control/ScaleLine
This commit is contained in:
@@ -91,11 +91,9 @@ const ScaleLine = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.renderedHTML_ = '';
|
this.renderedHTML_ = '';
|
||||||
|
|
||||||
const render = options.render ? options.render : ScaleLine.render;
|
|
||||||
|
|
||||||
Control.call(this, {
|
Control.call(this, {
|
||||||
element: this.element_,
|
element: this.element_,
|
||||||
render: render,
|
render: options.render || render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -129,7 +127,7 @@ ScaleLine.prototype.getUnits = function() {
|
|||||||
* @this {ol.control.ScaleLine}
|
* @this {ol.control.ScaleLine}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ScaleLine.render = function(mapEvent) {
|
export function render(mapEvent) {
|
||||||
const frameState = mapEvent.frameState;
|
const frameState = mapEvent.frameState;
|
||||||
if (!frameState) {
|
if (!frameState) {
|
||||||
this.viewState_ = null;
|
this.viewState_ = null;
|
||||||
@@ -137,7 +135,7 @@ ScaleLine.render = function(mapEvent) {
|
|||||||
this.viewState_ = frameState.viewState;
|
this.viewState_ = frameState.viewState;
|
||||||
}
|
}
|
||||||
this.updateElement_();
|
this.updateElement_();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import ScaleLine from '../../../../src/ol/control/ScaleLine.js';
|
import ScaleLine, {render} from '../../../../src/ol/control/ScaleLine.js';
|
||||||
import {fromLonLat} from '../../../../src/ol/proj.js';
|
import {fromLonLat} from '../../../../src/ol/proj.js';
|
||||||
import Projection from '../../../../src/ol/proj/Projection.js';
|
import Projection from '../../../../src/ol/proj/Projection.js';
|
||||||
|
|
||||||
@@ -67,12 +67,10 @@ describe('ol.control.ScaleLine', function() {
|
|||||||
describe('render', function() {
|
describe('render', function() {
|
||||||
it('defaults to `ol.control.ScaleLine.render`', function() {
|
it('defaults to `ol.control.ScaleLine.render`', function() {
|
||||||
const ctrl = new ScaleLine();
|
const ctrl = new ScaleLine();
|
||||||
expect(ctrl.render).to.be(ScaleLine.render);
|
expect(ctrl.render).to.be(render);
|
||||||
});
|
});
|
||||||
it('can be configured', function() {
|
it('can be configured', function() {
|
||||||
const myRender = function() {
|
const myRender = function() {};
|
||||||
|
|
||||||
};
|
|
||||||
const ctrl = new ScaleLine({
|
const ctrl = new ScaleLine({
|
||||||
render: myRender
|
render: myRender
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user