fixes #33: rotate around arbitrary point
This commit is contained in:
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
/* rotation */
|
||||
void rotateBy(double cx, double cy, double sx, double sy, double ex, double ey);
|
||||
void setAngle(double angle);
|
||||
void setAngle(double angle, double cx = -1, double cy = -1);
|
||||
double getAngle() const;
|
||||
void resetNorth();
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ class MBXMapView
|
||||
}
|
||||
else if (rotate.state == UIGestureRecognizerStateChanged)
|
||||
{
|
||||
mapView->map.setAngle(self.angle + rotate.rotation);
|
||||
mapView->map.setAngle(self.angle + rotate.rotation, [rotate locationInView:rotate.view].x, [rotate locationInView:rotate.view].y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,10 +93,24 @@ void Map::setScale(double scale) {
|
||||
settings.save();
|
||||
}
|
||||
|
||||
void Map::setAngle(double angle) {
|
||||
void Map::setAngle(double angle, double x, double y) {
|
||||
double dx, dy;
|
||||
|
||||
if (x >= 0 && y >= 0) {
|
||||
dx = (transform.width / 2) - x;
|
||||
dy = (transform.height / 2) - y;
|
||||
transform.moveBy(dx, dy);
|
||||
}
|
||||
|
||||
transform.setAngle(angle);
|
||||
|
||||
if (x >= 0 && y >= 0) {
|
||||
transform.moveBy(-dx, -dy);
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
transform.getLonLat(settings.longitude, settings.latitude);
|
||||
settings.angle = transform.getAngle();
|
||||
settings.save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user