Lint removal
This commit is contained in:
@@ -13,117 +13,117 @@ import Polygon from '../geom/Polygon.js';
|
||||
* @param {string} className CSS class name.
|
||||
*/
|
||||
class RenderBox {
|
||||
constructor(className) {
|
||||
constructor(className) {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {module:ol/geom/Polygon}
|
||||
* @private
|
||||
*/
|
||||
this.geometry_ = null;
|
||||
this.geometry_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {HTMLDivElement}
|
||||
* @private
|
||||
*/
|
||||
this.element_ = /** @type {HTMLDivElement} */ (document.createElement('div'));
|
||||
this.element_.style.position = 'absolute';
|
||||
this.element_.className = 'ol-box ' + className;
|
||||
this.element_ = /** @type {HTMLDivElement} */ (document.createElement('div'));
|
||||
this.element_.style.position = 'absolute';
|
||||
this.element_.className = 'ol-box ' + className;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol/PluggableMap}
|
||||
*/
|
||||
this.map_ = null;
|
||||
this.map_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
*/
|
||||
this.startPixel_ = null;
|
||||
this.startPixel_ = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
*/
|
||||
this.endPixel_ = null;
|
||||
this.endPixel_ = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
this.setMap(null);
|
||||
}
|
||||
disposeInternal() {
|
||||
this.setMap(null);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
render_() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const px = 'px';
|
||||
const style = this.element_.style;
|
||||
style.left = Math.min(startPixel[0], endPixel[0]) + px;
|
||||
style.top = Math.min(startPixel[1], endPixel[1]) + px;
|
||||
style.width = Math.abs(endPixel[0] - startPixel[0]) + px;
|
||||
style.height = Math.abs(endPixel[1] - startPixel[1]) + px;
|
||||
}
|
||||
render_() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const px = 'px';
|
||||
const style = this.element_.style;
|
||||
style.left = Math.min(startPixel[0], endPixel[0]) + px;
|
||||
style.top = Math.min(startPixel[1], endPixel[1]) + px;
|
||||
style.width = Math.abs(endPixel[0] - startPixel[0]) + px;
|
||||
style.height = Math.abs(endPixel[1] - startPixel[1]) + px;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol/PluggableMap} map Map.
|
||||
*/
|
||||
setMap(map) {
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().removeChild(this.element_);
|
||||
const style = this.element_.style;
|
||||
style.left = style.top = style.width = style.height = 'inherit';
|
||||
}
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().appendChild(this.element_);
|
||||
}
|
||||
}
|
||||
setMap(map) {
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().removeChild(this.element_);
|
||||
const style = this.element_.style;
|
||||
style.left = style.top = style.width = style.height = 'inherit';
|
||||
}
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().appendChild(this.element_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {module:ol~Pixel} startPixel Start pixel.
|
||||
* @param {module:ol~Pixel} endPixel End pixel.
|
||||
*/
|
||||
setPixels(startPixel, endPixel) {
|
||||
this.startPixel_ = startPixel;
|
||||
this.endPixel_ = endPixel;
|
||||
this.createOrUpdateGeometry();
|
||||
this.render_();
|
||||
}
|
||||
setPixels(startPixel, endPixel) {
|
||||
this.startPixel_ = startPixel;
|
||||
this.endPixel_ = endPixel;
|
||||
this.createOrUpdateGeometry();
|
||||
this.render_();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates or updates the cached geometry.
|
||||
*/
|
||||
createOrUpdateGeometry() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const pixels = [
|
||||
startPixel,
|
||||
[startPixel[0], endPixel[1]],
|
||||
endPixel,
|
||||
[endPixel[0], startPixel[1]]
|
||||
];
|
||||
const coordinates = pixels.map(this.map_.getCoordinateFromPixel, this.map_);
|
||||
// close the polygon
|
||||
coordinates[4] = coordinates[0].slice();
|
||||
if (!this.geometry_) {
|
||||
this.geometry_ = new Polygon([coordinates]);
|
||||
} else {
|
||||
this.geometry_.setCoordinates([coordinates]);
|
||||
}
|
||||
}
|
||||
createOrUpdateGeometry() {
|
||||
const startPixel = this.startPixel_;
|
||||
const endPixel = this.endPixel_;
|
||||
const pixels = [
|
||||
startPixel,
|
||||
[startPixel[0], endPixel[1]],
|
||||
endPixel,
|
||||
[endPixel[0], startPixel[1]]
|
||||
];
|
||||
const coordinates = pixels.map(this.map_.getCoordinateFromPixel, this.map_);
|
||||
// close the polygon
|
||||
coordinates[4] = coordinates[0].slice();
|
||||
if (!this.geometry_) {
|
||||
this.geometry_ = new Polygon([coordinates]);
|
||||
} else {
|
||||
this.geometry_.setCoordinates([coordinates]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return {module:ol/geom/Polygon} Geometry.
|
||||
*/
|
||||
getGeometry() {
|
||||
return this.geometry_;
|
||||
}
|
||||
getGeometry() {
|
||||
return this.geometry_;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(RenderBox, Disposable);
|
||||
|
||||
Reference in New Issue
Block a user