Rename _ol_control_MousePosition_ to MousePosition
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import _ol_Map_ from '../src/ol/Map.js';
|
import _ol_Map_ from '../src/ol/Map.js';
|
||||||
import _ol_View_ from '../src/ol/View.js';
|
import _ol_View_ from '../src/ol/View.js';
|
||||||
import _ol_control_ from '../src/ol/control.js';
|
import _ol_control_ from '../src/ol/control.js';
|
||||||
import _ol_control_MousePosition_ from '../src/ol/control/MousePosition.js';
|
import MousePosition from '../src/ol/control/MousePosition.js';
|
||||||
import _ol_coordinate_ from '../src/ol/coordinate.js';
|
import _ol_coordinate_ from '../src/ol/coordinate.js';
|
||||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||||
|
|
||||||
var mousePositionControl = new _ol_control_MousePosition_({
|
var mousePositionControl = new MousePosition({
|
||||||
coordinateFormat: _ol_coordinate_.createStringXY(4),
|
coordinateFormat: _ol_coordinate_.createStringXY(4),
|
||||||
projection: 'EPSG:4326',
|
projection: 'EPSG:4326',
|
||||||
// comment the following two lines to have the mouse position
|
// comment the following two lines to have the mouse position
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
|
|||||||
import _ol_style_Fill_ from '../src/ol/style/Fill.js';
|
import _ol_style_Fill_ from '../src/ol/style/Fill.js';
|
||||||
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
||||||
import _ol_style_Text_ from '../src/ol/style/Text.js';
|
import _ol_style_Text_ from '../src/ol/style/Text.js';
|
||||||
import _ol_control_MousePosition_ from '../src/ol/control/MousePosition.js';
|
import MousePosition from '../src/ol/control/MousePosition.js';
|
||||||
|
|
||||||
var raster = new _ol_layer_Tile_({
|
var raster = new _ol_layer_Tile_({
|
||||||
source: new _ol_source_OSM_()
|
source: new _ol_source_OSM_()
|
||||||
@@ -213,4 +213,4 @@ var snap = new _ol_interaction_Snap_({
|
|||||||
source: edges
|
source: edges
|
||||||
});
|
});
|
||||||
map.addInteraction(snap);
|
map.addInteraction(snap);
|
||||||
map.addControl(new _ol_control_MousePosition_());
|
map.addControl(new MousePosition());
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {getTransformFromProjections, identityTransform, get as getProjection} fr
|
|||||||
* options.
|
* options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_control_MousePosition_ = function(opt_options) {
|
var MousePosition = function(opt_options) {
|
||||||
|
|
||||||
var options = opt_options ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ var _ol_control_MousePosition_ = function(opt_options) {
|
|||||||
element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
|
element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
|
||||||
|
|
||||||
var render = options.render ?
|
var render = options.render ?
|
||||||
options.render : _ol_control_MousePosition_.render;
|
options.render : MousePosition.render;
|
||||||
|
|
||||||
Control.call(this, {
|
Control.call(this, {
|
||||||
element: element,
|
element: element,
|
||||||
@@ -39,7 +39,7 @@ var _ol_control_MousePosition_ = function(opt_options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
_ol_events_.listen(this,
|
_ol_events_.listen(this,
|
||||||
_ol_Object_.getChangeEventType(_ol_control_MousePosition_.Property_.PROJECTION),
|
_ol_Object_.getChangeEventType(MousePosition.Property_.PROJECTION),
|
||||||
this.handleProjectionChanged_, this);
|
this.handleProjectionChanged_, this);
|
||||||
|
|
||||||
if (options.coordinateFormat) {
|
if (options.coordinateFormat) {
|
||||||
@@ -81,7 +81,7 @@ var _ol_control_MousePosition_ = function(opt_options) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_control_MousePosition_, Control);
|
inherits(MousePosition, Control);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +90,7 @@ inherits(_ol_control_MousePosition_, Control);
|
|||||||
* @this {ol.control.MousePosition}
|
* @this {ol.control.MousePosition}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.render = function(mapEvent) {
|
MousePosition.render = function(mapEvent) {
|
||||||
var frameState = mapEvent.frameState;
|
var frameState = mapEvent.frameState;
|
||||||
if (!frameState) {
|
if (!frameState) {
|
||||||
this.mapProjection_ = null;
|
this.mapProjection_ = null;
|
||||||
@@ -107,7 +107,7 @@ _ol_control_MousePosition_.render = function(mapEvent) {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.handleProjectionChanged_ = function() {
|
MousePosition.prototype.handleProjectionChanged_ = function() {
|
||||||
this.transform_ = null;
|
this.transform_ = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,9 +120,9 @@ _ol_control_MousePosition_.prototype.handleProjectionChanged_ = function() {
|
|||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.getCoordinateFormat = function() {
|
MousePosition.prototype.getCoordinateFormat = function() {
|
||||||
return (
|
return (
|
||||||
/** @type {ol.CoordinateFormatType|undefined} */ this.get(_ol_control_MousePosition_.Property_.COORDINATE_FORMAT)
|
/** @type {ol.CoordinateFormatType|undefined} */ this.get(MousePosition.Property_.COORDINATE_FORMAT)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ _ol_control_MousePosition_.prototype.getCoordinateFormat = function() {
|
|||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.getProjection = function() {
|
MousePosition.prototype.getProjection = function() {
|
||||||
return (
|
return (
|
||||||
/** @type {ol.proj.Projection|undefined} */ this.get(_ol_control_MousePosition_.Property_.PROJECTION)
|
/** @type {ol.proj.Projection|undefined} */ this.get(MousePosition.Property_.PROJECTION)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ _ol_control_MousePosition_.prototype.getProjection = function() {
|
|||||||
* @param {Event} event Browser event.
|
* @param {Event} event Browser event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.handleMouseMove = function(event) {
|
MousePosition.prototype.handleMouseMove = function(event) {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
this.lastMouseMovePixel_ = map.getEventPixel(event);
|
this.lastMouseMovePixel_ = map.getEventPixel(event);
|
||||||
this.updateHTML_(this.lastMouseMovePixel_);
|
this.updateHTML_(this.lastMouseMovePixel_);
|
||||||
@@ -156,7 +156,7 @@ _ol_control_MousePosition_.prototype.handleMouseMove = function(event) {
|
|||||||
* @param {Event} event Browser event.
|
* @param {Event} event Browser event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.handleMouseOut = function(event) {
|
MousePosition.prototype.handleMouseOut = function(event) {
|
||||||
this.updateHTML_(null);
|
this.updateHTML_(null);
|
||||||
this.lastMouseMovePixel_ = null;
|
this.lastMouseMovePixel_ = null;
|
||||||
};
|
};
|
||||||
@@ -166,7 +166,7 @@ _ol_control_MousePosition_.prototype.handleMouseOut = function(event) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.setMap = function(map) {
|
MousePosition.prototype.setMap = function(map) {
|
||||||
Control.prototype.setMap.call(this, map);
|
Control.prototype.setMap.call(this, map);
|
||||||
if (map) {
|
if (map) {
|
||||||
var viewport = map.getViewport();
|
var viewport = map.getViewport();
|
||||||
@@ -187,8 +187,8 @@ _ol_control_MousePosition_.prototype.setMap = function(map) {
|
|||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.setCoordinateFormat = function(format) {
|
MousePosition.prototype.setCoordinateFormat = function(format) {
|
||||||
this.set(_ol_control_MousePosition_.Property_.COORDINATE_FORMAT, format);
|
this.set(MousePosition.Property_.COORDINATE_FORMAT, format);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -199,8 +199,8 @@ _ol_control_MousePosition_.prototype.setCoordinateFormat = function(format) {
|
|||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.setProjection = function(projection) {
|
MousePosition.prototype.setProjection = function(projection) {
|
||||||
this.set(_ol_control_MousePosition_.Property_.PROJECTION, getProjection(projection));
|
this.set(MousePosition.Property_.PROJECTION, getProjection(projection));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ _ol_control_MousePosition_.prototype.setProjection = function(projection) {
|
|||||||
* @param {?ol.Pixel} pixel Pixel.
|
* @param {?ol.Pixel} pixel Pixel.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.prototype.updateHTML_ = function(pixel) {
|
MousePosition.prototype.updateHTML_ = function(pixel) {
|
||||||
var html = this.undefinedHTML_;
|
var html = this.undefinedHTML_;
|
||||||
if (pixel && this.mapProjection_) {
|
if (pixel && this.mapProjection_) {
|
||||||
if (!this.transform_) {
|
if (!this.transform_) {
|
||||||
@@ -243,8 +243,8 @@ _ol_control_MousePosition_.prototype.updateHTML_ = function(pixel) {
|
|||||||
* @enum {string}
|
* @enum {string}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_control_MousePosition_.Property_ = {
|
MousePosition.Property_ = {
|
||||||
PROJECTION: 'projection',
|
PROJECTION: 'projection',
|
||||||
COORDINATE_FORMAT: 'coordinateFormat'
|
COORDINATE_FORMAT: 'coordinateFormat'
|
||||||
};
|
};
|
||||||
export default _ol_control_MousePosition_;
|
export default MousePosition;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import _ol_control_MousePosition_ from '../../../../src/ol/control/MousePosition.js';
|
import MousePosition from '../../../../src/ol/control/MousePosition.js';
|
||||||
|
|
||||||
describe('ol.control.MousePosition', function() {
|
describe('ol.control.MousePosition', function() {
|
||||||
|
|
||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
|
|
||||||
it('can be constructed without arguments', function() {
|
it('can be constructed without arguments', function() {
|
||||||
var instance = new _ol_control_MousePosition_();
|
var instance = new MousePosition();
|
||||||
expect(instance).to.be.an(_ol_control_MousePosition_);
|
expect(instance).to.be.an(MousePosition);
|
||||||
expect(instance.element.className).to.be('ol-mouse-position');
|
expect(instance.element.className).to.be('ol-mouse-position');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates the element with the provided class name', function() {
|
it('creates the element with the provided class name', function() {
|
||||||
var className = 'foobar';
|
var className = 'foobar';
|
||||||
var instance = new _ol_control_MousePosition_({
|
var instance = new MousePosition({
|
||||||
className: className
|
className: className
|
||||||
});
|
});
|
||||||
expect(instance.element.className).to.be(className);
|
expect(instance.element.className).to.be(className);
|
||||||
|
|||||||
Reference in New Issue
Block a user