Call event.getPixel() to get the map pixel offset
The new getPixel method should be used instead of checking offsetX/Y on the browser event.
This commit is contained in:
@@ -30,9 +30,10 @@ ol.interaction.AltDragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
|||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
|
var offset = mapBrowserEvent.getPixel();
|
||||||
var theta = Math.atan2(
|
var theta = Math.atan2(
|
||||||
size.height / 2 - browserEvent.offsetY,
|
size.height / 2 - offset.y,
|
||||||
browserEvent.offsetX - size.width / 2);
|
offset.x - size.width / 2);
|
||||||
map.rotate(this.startRotation_, -theta);
|
map.rotate(this.startRotation_, -theta);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,9 +48,10 @@ ol.interaction.AltDragRotate.prototype.handleDragStart =
|
|||||||
if (browserEvent.isMouseActionButton() && browserEvent.altKey &&
|
if (browserEvent.isMouseActionButton() && browserEvent.altKey &&
|
||||||
map.canRotate()) {
|
map.canRotate()) {
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
|
var offset = mapBrowserEvent.getPixel();
|
||||||
var theta = Math.atan2(
|
var theta = Math.atan2(
|
||||||
size.height / 2 - browserEvent.offsetY,
|
size.height / 2 - offset.y,
|
||||||
browserEvent.offsetX - size.width / 2);
|
offset.x - size.width / 2);
|
||||||
this.startRotation_ = (map.getRotation() || 0) + theta;
|
this.startRotation_ = (map.getRotation() || 0) + theta;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user