diff --git a/examples/overviewmap-custom.js b/examples/overviewmap-custom.js index 643e14ef9e..d859af0a31 100644 --- a/examples/overviewmap-custom.js +++ b/examples/overviewmap-custom.js @@ -1,14 +1,14 @@ 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_OverviewMap_ from '../src/ol/control/OverviewMap.js'; +import OverviewMap from '../src/ol/control/OverviewMap.js'; import _ol_interaction_ from '../src/ol/interaction.js'; import _ol_interaction_DragRotateAndZoom_ from '../src/ol/interaction/DragRotateAndZoom.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js'; -var overviewMapControl = new _ol_control_OverviewMap_({ +var overviewMapControl = new OverviewMap({ // see in overviewmap-custom.html to see the custom CSS used className: 'ol-overviewmap ol-custom-overviewmap', layers: [ diff --git a/examples/overviewmap.js b/examples/overviewmap.js index 8a887ae5fc..1b8f09a982 100644 --- a/examples/overviewmap.js +++ b/examples/overviewmap.js @@ -1,13 +1,13 @@ 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_OverviewMap_ from '../src/ol/control/OverviewMap.js'; +import OverviewMap from '../src/ol/control/OverviewMap.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js'; var map = new _ol_Map_({ controls: _ol_control_.defaults().extend([ - new _ol_control_OverviewMap_() + new OverviewMap() ]), layers: [ new _ol_layer_Tile_({ diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 29fb4465c2..cb4bf80c3b 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -42,7 +42,7 @@ var MIN_RATIO = 0.1; * @param {olx.control.OverviewMapOptions=} opt_options OverviewMap options. * @api */ -var _ol_control_OverviewMap_ = function(opt_options) { +var OverviewMap = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -156,7 +156,7 @@ var _ol_control_OverviewMap_ = function(opt_options) { element.appendChild(this.ovmapDiv_); element.appendChild(button); - var render = options.render ? options.render : _ol_control_OverviewMap_.render; + var render = options.render ? options.render : OverviewMap.render; Control.call(this, { element: element, @@ -203,14 +203,14 @@ var _ol_control_OverviewMap_ = function(opt_options) { }); }; -inherits(_ol_control_OverviewMap_, Control); +inherits(OverviewMap, Control); /** * @inheritDoc * @api */ -_ol_control_OverviewMap_.prototype.setMap = function(map) { +OverviewMap.prototype.setMap = function(map) { var oldMap = this.getMap(); if (map === oldMap) { return; @@ -252,7 +252,7 @@ _ol_control_OverviewMap_.prototype.setMap = function(map) { * @param {ol.Object.Event} event The propertychange event. * @private */ -_ol_control_OverviewMap_.prototype.handleMapPropertyChange_ = function(event) { +OverviewMap.prototype.handleMapPropertyChange_ = function(event) { if (event.key === _ol_MapProperty_.VIEW) { var oldView = /** @type {ol.View} */ (event.oldValue); if (oldView) { @@ -269,7 +269,7 @@ _ol_control_OverviewMap_.prototype.handleMapPropertyChange_ = function(event) { * @param {ol.View} view The view. * @private */ -_ol_control_OverviewMap_.prototype.bindView_ = function(view) { +OverviewMap.prototype.bindView_ = function(view) { _ol_events_.listen(view, _ol_Object_.getChangeEventType(_ol_ViewProperty_.ROTATION), this.handleRotationChanged_, this); @@ -281,7 +281,7 @@ _ol_control_OverviewMap_.prototype.bindView_ = function(view) { * @param {ol.View} view The view. * @private */ -_ol_control_OverviewMap_.prototype.unbindView_ = function(view) { +OverviewMap.prototype.unbindView_ = function(view) { _ol_events_.unlisten(view, _ol_Object_.getChangeEventType(_ol_ViewProperty_.ROTATION), this.handleRotationChanged_, this); @@ -294,7 +294,7 @@ _ol_control_OverviewMap_.prototype.unbindView_ = function(view) { * overview map's view. * @private */ -_ol_control_OverviewMap_.prototype.handleRotationChanged_ = function() { +OverviewMap.prototype.handleRotationChanged_ = function() { this.ovmap_.getView().setRotation(this.getMap().getView().getRotation()); }; @@ -305,7 +305,7 @@ _ol_control_OverviewMap_.prototype.handleRotationChanged_ = function() { * @this {ol.control.OverviewMap} * @api */ -_ol_control_OverviewMap_.render = function(mapEvent) { +OverviewMap.render = function(mapEvent) { this.validateExtent_(); this.updateBox_(); }; @@ -322,7 +322,7 @@ _ol_control_OverviewMap_.render = function(mapEvent) { * main map center location. * @private */ -_ol_control_OverviewMap_.prototype.validateExtent_ = function() { +OverviewMap.prototype.validateExtent_ = function() { var map = this.getMap(); var ovmap = this.ovmap_; @@ -367,7 +367,7 @@ _ol_control_OverviewMap_.prototype.validateExtent_ = function() { * the extent of the main map. * @private */ -_ol_control_OverviewMap_.prototype.resetExtent_ = function() { +OverviewMap.prototype.resetExtent_ = function() { if (MAX_RATIO === 0 || MIN_RATIO === 0) { return; } @@ -398,7 +398,7 @@ _ol_control_OverviewMap_.prototype.resetExtent_ = function() { * resolution. * @private */ -_ol_control_OverviewMap_.prototype.recenter_ = function() { +OverviewMap.prototype.recenter_ = function() { var map = this.getMap(); var ovmap = this.ovmap_; @@ -414,7 +414,7 @@ _ol_control_OverviewMap_.prototype.recenter_ = function() { * Update the box using the main map extent * @private */ -_ol_control_OverviewMap_.prototype.updateBox_ = function() { +OverviewMap.prototype.updateBox_ = function() { var map = this.getMap(); var ovmap = this.ovmap_; @@ -455,7 +455,7 @@ _ol_control_OverviewMap_.prototype.updateBox_ = function() { * @return {ol.Coordinate|undefined} Coordinate for rotation and center anchor. * @private */ -_ol_control_OverviewMap_.prototype.calculateCoordinateRotate_ = function( +OverviewMap.prototype.calculateCoordinateRotate_ = function( rotation, coordinate) { var coordinateRotate; @@ -480,7 +480,7 @@ _ol_control_OverviewMap_.prototype.calculateCoordinateRotate_ = function( * @param {Event} event The event to handle * @private */ -_ol_control_OverviewMap_.prototype.handleClick_ = function(event) { +OverviewMap.prototype.handleClick_ = function(event) { event.preventDefault(); this.handleToggle_(); }; @@ -489,7 +489,7 @@ _ol_control_OverviewMap_.prototype.handleClick_ = function(event) { /** * @private */ -_ol_control_OverviewMap_.prototype.handleToggle_ = function() { +OverviewMap.prototype.handleToggle_ = function() { this.element.classList.toggle('ol-collapsed'); if (this.collapsed_) { replaceNode(this.collapseLabel_, this.label_); @@ -518,7 +518,7 @@ _ol_control_OverviewMap_.prototype.handleToggle_ = function() { * @return {boolean} True if the widget is collapsible. * @api */ -_ol_control_OverviewMap_.prototype.getCollapsible = function() { +OverviewMap.prototype.getCollapsible = function() { return this.collapsible_; }; @@ -528,7 +528,7 @@ _ol_control_OverviewMap_.prototype.getCollapsible = function() { * @param {boolean} collapsible True if the widget is collapsible. * @api */ -_ol_control_OverviewMap_.prototype.setCollapsible = function(collapsible) { +OverviewMap.prototype.setCollapsible = function(collapsible) { if (this.collapsible_ === collapsible) { return; } @@ -547,7 +547,7 @@ _ol_control_OverviewMap_.prototype.setCollapsible = function(collapsible) { * @param {boolean} collapsed True if the widget is collapsed. * @api */ -_ol_control_OverviewMap_.prototype.setCollapsed = function(collapsed) { +OverviewMap.prototype.setCollapsed = function(collapsed) { if (!this.collapsible_ || this.collapsed_ === collapsed) { return; } @@ -560,7 +560,7 @@ _ol_control_OverviewMap_.prototype.setCollapsed = function(collapsed) { * @return {boolean} The overview map is collapsed. * @api */ -_ol_control_OverviewMap_.prototype.getCollapsed = function() { +OverviewMap.prototype.getCollapsed = function() { return this.collapsed_; }; @@ -570,7 +570,7 @@ _ol_control_OverviewMap_.prototype.getCollapsed = function() { * @return {ol.PluggableMap} Overview map. * @api */ -_ol_control_OverviewMap_.prototype.getOverviewMap = function() { +OverviewMap.prototype.getOverviewMap = function() { return this.ovmap_; }; -export default _ol_control_OverviewMap_; +export default OverviewMap; diff --git a/test/spec/ol/control/overviewmap.test.js b/test/spec/ol/control/overviewmap.test.js index 2d4586c990..d7a976fcdf 100644 --- a/test/spec/ol/control/overviewmap.test.js +++ b/test/spec/ol/control/overviewmap.test.js @@ -1,7 +1,7 @@ import _ol_Map_ from '../../../../src/ol/Map.js'; import _ol_View_ from '../../../../src/ol/View.js'; import Control from '../../../../src/ol/control/Control.js'; -import _ol_control_OverviewMap_ from '../../../../src/ol/control/OverviewMap.js'; +import OverviewMap from '../../../../src/ol/control/OverviewMap.js'; describe('ol.control.OverviewMap', function() { var map, target; @@ -23,8 +23,8 @@ describe('ol.control.OverviewMap', function() { describe('constructor', function() { it('creates an overview map with the default options', function() { - var control = new _ol_control_OverviewMap_(); - expect(control).to.be.a(_ol_control_OverviewMap_); + var control = new OverviewMap(); + expect(control).to.be.a(OverviewMap); expect(control).to.be.a(Control); }); }); @@ -39,7 +39,7 @@ describe('ol.control.OverviewMap', function() { }); map.setView(view); - var control = new _ol_control_OverviewMap_(); + var control = new OverviewMap(); map.addControl(control); var ovView = control.ovmap_.getView(); expect(ovView.getRotation()).to.be(0); @@ -49,7 +49,7 @@ describe('ol.control.OverviewMap', function() { }); it('maintains rotation in sync if view added later', function() { - var control = new _ol_control_OverviewMap_(); + var control = new OverviewMap(); map.addControl(control); var ovView = control.ovmap_.getView(); expect(ovView.getRotation()).to.be(0); @@ -65,7 +65,7 @@ describe('ol.control.OverviewMap', function() { }); it('stops listening to old maps', function() { - var control = new _ol_control_OverviewMap_(); + var control = new OverviewMap(); var ovView = control.ovmap_.getView(); var view = new _ol_View_({ @@ -86,7 +86,7 @@ describe('ol.control.OverviewMap', function() { }); it('set target to null', function() { - var control = new _ol_control_OverviewMap_(); + var control = new OverviewMap(); map.addControl(control);