Use extends and super for control/OverviewMap
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/control/OverviewMap
|
* @module ol/control/OverviewMap
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../util.js';
|
|
||||||
import Collection from '../Collection.js';
|
import Collection from '../Collection.js';
|
||||||
import Map from '../Map.js';
|
import Map from '../Map.js';
|
||||||
import MapEventType from '../MapEventType.js';
|
import MapEventType from '../MapEventType.js';
|
||||||
@@ -62,15 +61,20 @@ const MIN_RATIO = 0.1;
|
|||||||
* Create a new control with a map acting as an overview map for an other
|
* Create a new control with a map acting as an overview map for an other
|
||||||
* defined map.
|
* defined map.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {module:ol/control/Control}
|
|
||||||
* @param {module:ol/control/OverviewMap~Options=} opt_options OverviewMap options.
|
* @param {module:ol/control/OverviewMap~Options=} opt_options OverviewMap options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class OverviewMap {
|
class OverviewMap extends Control {
|
||||||
constructor(opt_options) {
|
constructor(opt_options) {
|
||||||
|
|
||||||
const options = opt_options ? opt_options : {};
|
const options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
|
super({
|
||||||
|
element: document.createElement('div'),
|
||||||
|
render: options.render || render,
|
||||||
|
target: options.target
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @private
|
||||||
@@ -175,17 +179,11 @@ class OverviewMap {
|
|||||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||||
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
|
(this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
|
||||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||||
const element = document.createElement('div');
|
const element = this.element;
|
||||||
element.className = cssClasses;
|
element.className = cssClasses;
|
||||||
element.appendChild(this.ovmapDiv_);
|
element.appendChild(this.ovmapDiv_);
|
||||||
element.appendChild(button);
|
element.appendChild(button);
|
||||||
|
|
||||||
Control.call(this, {
|
|
||||||
element: element,
|
|
||||||
render: options.render || render,
|
|
||||||
target: options.target
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Interactive map */
|
/* Interactive map */
|
||||||
|
|
||||||
const scope = this;
|
const scope = this;
|
||||||
@@ -241,7 +239,7 @@ class OverviewMap {
|
|||||||
}
|
}
|
||||||
this.ovmap_.setTarget(null);
|
this.ovmap_.setTarget(null);
|
||||||
}
|
}
|
||||||
Control.prototype.setMap.call(this, map);
|
super.setMap(map);
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
this.ovmap_.setTarget(this.ovmapDiv_);
|
this.ovmap_.setTarget(this.ovmapDiv_);
|
||||||
@@ -565,8 +563,6 @@ class OverviewMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(OverviewMap, Control);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the overview map element.
|
* Update the overview map element.
|
||||||
|
|||||||
Reference in New Issue
Block a user