Seperate getEventCoordinate into internal/external method

This commit is contained in:
Tobias Kohr
2019-09-23 19:22:36 +02:00
parent 686c185de3
commit 5711cd30d0
5 changed files with 16 additions and 7 deletions

View File

@@ -135,7 +135,7 @@ map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
const coordinate = map.getEventCoordinate(evt.originalEvent);
const coordinate = map.getEventCoordinateExternal(evt.originalEvent);
displaySnap(coordinate);
});

View File

@@ -85,7 +85,7 @@ map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
const coordinate = map.getEventCoordinate(evt.originalEvent);
const coordinate = map.getEventCoordinateExternal(evt.originalEvent);
displaySnap(coordinate);
});

View File

@@ -63,7 +63,7 @@ map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
const coordinate = map.getEventCoordinate(evt.originalEvent);
const coordinate = map.getEventCoordinateExternal(evt.originalEvent);
displayCountryInfo(coordinate);
});

View File

@@ -629,15 +629,24 @@ class PluggableMap extends BaseObject {
}
/**
* Returns the coordinate in view projection for a browser event.
* Returns the coordinate in user projection for a browser event.
* @param {Event} event Event.
* @return {import("./coordinate.js").Coordinate} Coordinate.
* @api
*/
getEventCoordinate(event) {
getEventCoordinateExternal(event) {
return this.getCoordinateFromPixelExternal(this.getEventPixel(event));
}
/**
* Returns the coordinate in view projection for a browser event.
* @param {Event} event Event.
* @return {import("./coordinate.js").Coordinate} Coordinate.
*/
getEventCoordinateInternal(event) {
return this.getCoordinateFromPixelInternal(this.getEventPixel(event));
}
/**
* Returns the map pixel position for a browser event relative to the viewport.
* @param {Event|TouchEvent} event Event.

View File

@@ -223,13 +223,13 @@ class OverviewMap extends Control {
const move = function(event) {
const position = /** @type {?} */ (computeDesiredMousePosition(event));
const coordinates = ovmap.getEventCoordinate(/** @type {Event} */ (position));
const coordinates = ovmap.getEventCoordinateInternal(/** @type {Event} */ (position));
overlay.setPosition(coordinates);
};
const endMoving = function(event) {
const coordinates = ovmap.getEventCoordinate(event);
const coordinates = ovmap.getEventCoordinateInternal(event);
scope.getMap().getView().setCenterInternal(coordinates);