Rename _ol_control_ScaleLine_ to ScaleLine
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import _ol_Map_ from '../src/ol/Map.js';
|
||||
import _ol_View_ from '../src/ol/View.js';
|
||||
import _ol_control_ from '../src/ol/control.js';
|
||||
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
|
||||
import ScaleLine from '../src/ol/control/ScaleLine.js';
|
||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
|
||||
|
||||
@@ -20,7 +20,7 @@ var layers = [
|
||||
|
||||
var map = new _ol_Map_({
|
||||
controls: _ol_control_.defaults().extend([
|
||||
new _ol_control_ScaleLine_({
|
||||
new ScaleLine({
|
||||
units: 'degrees'
|
||||
})
|
||||
]),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import _ol_Map_ from '../src/ol/Map.js';
|
||||
import _ol_View_ from '../src/ol/View.js';
|
||||
import _ol_control_ from '../src/ol/control.js';
|
||||
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
|
||||
import ScaleLine from '../src/ol/control/ScaleLine.js';
|
||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||
|
||||
|
||||
var scaleLineControl = new _ol_control_ScaleLine_();
|
||||
var scaleLineControl = new ScaleLine();
|
||||
|
||||
var map = new _ol_Map_({
|
||||
controls: _ol_control_.defaults({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ol_Map_ from '../src/ol/Map.js';
|
||||
import _ol_View_ from '../src/ol/View.js';
|
||||
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
|
||||
import ScaleLine from '../src/ol/control/ScaleLine.js';
|
||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||
import {fromLonLat, transformExtent} from '../src/ol/proj.js';
|
||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||
@@ -32,4 +32,4 @@ var map = new _ol_Map_({
|
||||
})
|
||||
});
|
||||
|
||||
map.addControl(new _ol_control_ScaleLine_({units: 'us'}));
|
||||
map.addControl(new ScaleLine({units: 'us'}));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ol_Map_ from '../src/ol/Map.js';
|
||||
import _ol_View_ from '../src/ol/View.js';
|
||||
import _ol_control_ from '../src/ol/control.js';
|
||||
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
|
||||
import ScaleLine from '../src/ol/control/ScaleLine.js';
|
||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||
import {addProjection, addCoordinateTransforms, transform} from '../src/ol/proj.js';
|
||||
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
|
||||
@@ -71,7 +71,7 @@ var layers = [
|
||||
|
||||
var map = new _ol_Map_({
|
||||
controls: _ol_control_.defaults().extend([
|
||||
new _ol_control_ScaleLine_({
|
||||
new ScaleLine({
|
||||
units: 'metric'
|
||||
})
|
||||
]),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ol_Map_ from '../src/ol/Map.js';
|
||||
import _ol_View_ from '../src/ol/View.js';
|
||||
import _ol_control_ from '../src/ol/control.js';
|
||||
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
|
||||
import ScaleLine from '../src/ol/control/ScaleLine.js';
|
||||
import _ol_layer_Image_ from '../src/ol/layer/Image.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
|
||||
@@ -59,7 +59,7 @@ var layers = [
|
||||
|
||||
var map = new _ol_Map_({
|
||||
controls: _ol_control_.defaults().extend([
|
||||
new _ol_control_ScaleLine_()
|
||||
new ScaleLine()
|
||||
]),
|
||||
layers: layers,
|
||||
target: 'map',
|
||||
|
||||
@@ -26,7 +26,7 @@ import _ol_proj_Units_ from '../proj/Units.js';
|
||||
* @param {olx.control.ScaleLineOptions=} opt_options Scale line options.
|
||||
* @api
|
||||
*/
|
||||
var _ol_control_ScaleLine_ = function(opt_options) {
|
||||
var ScaleLine = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
|
||||
@@ -77,7 +77,7 @@ var _ol_control_ScaleLine_ = function(opt_options) {
|
||||
*/
|
||||
this.renderedHTML_ = '';
|
||||
|
||||
var render = options.render ? options.render : _ol_control_ScaleLine_.render;
|
||||
var render = options.render ? options.render : ScaleLine.render;
|
||||
|
||||
Control.call(this, {
|
||||
element: this.element_,
|
||||
@@ -86,7 +86,7 @@ var _ol_control_ScaleLine_ = function(opt_options) {
|
||||
});
|
||||
|
||||
_ol_events_.listen(
|
||||
this, _ol_Object_.getChangeEventType(_ol_control_ScaleLine_.Property_.UNITS),
|
||||
this, _ol_Object_.getChangeEventType(ScaleLine.Property_.UNITS),
|
||||
this.handleUnitsChanged_, this);
|
||||
|
||||
this.setUnits(/** @type {ol.control.ScaleLineUnits} */ (options.units) ||
|
||||
@@ -94,14 +94,14 @@ var _ol_control_ScaleLine_ = function(opt_options) {
|
||||
|
||||
};
|
||||
|
||||
inherits(_ol_control_ScaleLine_, Control);
|
||||
inherits(ScaleLine, Control);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
_ol_control_ScaleLine_.LEADING_DIGITS = [1, 2, 5];
|
||||
ScaleLine.LEADING_DIGITS = [1, 2, 5];
|
||||
|
||||
|
||||
/**
|
||||
@@ -111,9 +111,9 @@ _ol_control_ScaleLine_.LEADING_DIGITS = [1, 2, 5];
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
_ol_control_ScaleLine_.prototype.getUnits = function() {
|
||||
ScaleLine.prototype.getUnits = function() {
|
||||
return (
|
||||
/** @type {ol.control.ScaleLineUnits|undefined} */ this.get(_ol_control_ScaleLine_.Property_.UNITS)
|
||||
/** @type {ol.control.ScaleLineUnits|undefined} */ this.get(ScaleLine.Property_.UNITS)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -124,7 +124,7 @@ _ol_control_ScaleLine_.prototype.getUnits = function() {
|
||||
* @this {ol.control.ScaleLine}
|
||||
* @api
|
||||
*/
|
||||
_ol_control_ScaleLine_.render = function(mapEvent) {
|
||||
ScaleLine.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
if (!frameState) {
|
||||
this.viewState_ = null;
|
||||
@@ -138,7 +138,7 @@ _ol_control_ScaleLine_.render = function(mapEvent) {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_ol_control_ScaleLine_.prototype.handleUnitsChanged_ = function() {
|
||||
ScaleLine.prototype.handleUnitsChanged_ = function() {
|
||||
this.updateElement_();
|
||||
};
|
||||
|
||||
@@ -149,15 +149,15 @@ _ol_control_ScaleLine_.prototype.handleUnitsChanged_ = function() {
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
_ol_control_ScaleLine_.prototype.setUnits = function(units) {
|
||||
this.set(_ol_control_ScaleLine_.Property_.UNITS, units);
|
||||
ScaleLine.prototype.setUnits = function(units) {
|
||||
this.set(ScaleLine.Property_.UNITS, units);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_ol_control_ScaleLine_.prototype.updateElement_ = function() {
|
||||
ScaleLine.prototype.updateElement_ = function() {
|
||||
var viewState = this.viewState_;
|
||||
|
||||
if (!viewState) {
|
||||
@@ -244,7 +244,7 @@ _ol_control_ScaleLine_.prototype.updateElement_ = function() {
|
||||
Math.log(this.minWidth_ * pointResolution) / Math.log(10));
|
||||
var count, width;
|
||||
while (true) {
|
||||
count = _ol_control_ScaleLine_.LEADING_DIGITS[((i % 3) + 3) % 3] *
|
||||
count = ScaleLine.LEADING_DIGITS[((i % 3) + 3) % 3] *
|
||||
Math.pow(10, Math.floor(i / 3));
|
||||
width = Math.round(count / pointResolution);
|
||||
if (isNaN(width)) {
|
||||
@@ -280,7 +280,7 @@ _ol_control_ScaleLine_.prototype.updateElement_ = function() {
|
||||
* @enum {string}
|
||||
* @private
|
||||
*/
|
||||
_ol_control_ScaleLine_.Property_ = {
|
||||
ScaleLine.Property_ = {
|
||||
UNITS: 'units'
|
||||
};
|
||||
export default _ol_control_ScaleLine_;
|
||||
export default ScaleLine;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_control_ScaleLine_ from '../../../../src/ol/control/ScaleLine.js';
|
||||
import ScaleLine from '../../../../src/ol/control/ScaleLine.js';
|
||||
import {fromLonLat} from '../../../../src/ol/proj.js';
|
||||
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
|
||||
|
||||
@@ -20,8 +20,8 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('can be constructed without arguments', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl).to.be.an(_ol_control_ScaleLine_);
|
||||
var ctrl = new ScaleLine();
|
||||
expect(ctrl).to.be.an(ScaleLine);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,14 +29,14 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('className', function() {
|
||||
it('defaults to "ol-scale-line"', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
ctrl.setMap(map);
|
||||
var element = document.querySelector('.ol-scale-line', map.getTarget());
|
||||
expect(element).to.not.be(null);
|
||||
expect(element).to.be.a(HTMLDivElement);
|
||||
});
|
||||
it('can be configured', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
className: 'humpty-dumpty'
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
@@ -53,11 +53,11 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('minWidth', function() {
|
||||
it('defaults to 64', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
expect(ctrl.minWidth_).to.be(64);
|
||||
});
|
||||
it('can be configured', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
minWidth: 4711
|
||||
});
|
||||
expect(ctrl.minWidth_).to.be(4711);
|
||||
@@ -66,14 +66,14 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('render', function() {
|
||||
it('defaults to `ol.control.ScaleLine.render`', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
expect(ctrl.render).to.be(_ol_control_ScaleLine_.render);
|
||||
var ctrl = new ScaleLine();
|
||||
expect(ctrl.render).to.be(ScaleLine.render);
|
||||
});
|
||||
it('can be configured', function() {
|
||||
var myRender = function() {
|
||||
|
||||
};
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
render: myRender
|
||||
});
|
||||
expect(ctrl.render).to.be(myRender);
|
||||
@@ -85,7 +85,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
describe('synchronisation with map view', function() {
|
||||
it('calls `render` as soon as the map is rendered', function(done) {
|
||||
var renderSpy = sinon.spy();
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
render: renderSpy
|
||||
});
|
||||
expect(renderSpy.called).to.be(false);
|
||||
@@ -104,7 +104,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
it('calls `render` as often as the map is rendered', function() {
|
||||
var renderSpy = sinon.spy();
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
render: renderSpy
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
@@ -121,7 +121,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
it('calls `render` as when the view changes', function(done) {
|
||||
var renderSpy = sinon.spy();
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
render: renderSpy
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
@@ -140,7 +140,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('static method `render`', function() {
|
||||
it('updates the rendered text', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
expect(ctrl.element.innerText).to.be('');
|
||||
ctrl.setMap(map);
|
||||
map.setView(new _ol_View_({
|
||||
@@ -154,17 +154,17 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('#getUnits', function() {
|
||||
it('returns "metric" by default', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
expect(ctrl.getUnits()).to.be('metric');
|
||||
});
|
||||
it('returns what is configured via `units` property', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
units: 'nautical'
|
||||
});
|
||||
expect(ctrl.getUnits()).to.be('nautical');
|
||||
});
|
||||
it('returns what is configured `setUnits` method', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
ctrl.setUnits('nautical');
|
||||
expect(ctrl.getUnits()).to.be('nautical');
|
||||
});
|
||||
@@ -172,7 +172,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('#setUnits', function() {
|
||||
it('triggers rerendering', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
@@ -196,7 +196,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
var imperialHtml;
|
||||
var usHtml;
|
||||
beforeEach(function(done) {
|
||||
ctrl = new _ol_control_ScaleLine_();
|
||||
ctrl = new ScaleLine();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
@@ -246,7 +246,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
|
||||
describe('projections affect the scaleline', function() {
|
||||
it('is rendered differently for different projections', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new _ol_View_({
|
||||
center: fromLonLat([7, 52]),
|
||||
@@ -266,7 +266,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
|
||||
it('Projection\'s metersPerUnit affect scale for non-degree units', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new _ol_View_({
|
||||
center: [0, 0],
|
||||
@@ -303,7 +303,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
describe('latitude may affect scale line in EPSG:4326', function() {
|
||||
|
||||
it('is rendered differently at different latitudes for metric', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_();
|
||||
var ctrl = new ScaleLine();
|
||||
ctrl.setMap(map);
|
||||
map.setView(new _ol_View_({
|
||||
center: fromLonLat([7, 0]),
|
||||
@@ -319,7 +319,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
});
|
||||
|
||||
it('is rendered the same at different latitudes for degrees', function() {
|
||||
var ctrl = new _ol_control_ScaleLine_({
|
||||
var ctrl = new ScaleLine({
|
||||
units: 'degrees'
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
@@ -359,7 +359,7 @@ describe('ol.control.ScaleLine', function() {
|
||||
beforeEach(function() {
|
||||
currentZoom = 33;
|
||||
renderedHtmls = {};
|
||||
ctrl = new _ol_control_ScaleLine_({
|
||||
ctrl = new ScaleLine({
|
||||
minWidth: 10
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
|
||||
Reference in New Issue
Block a user