diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 5c18c879188..46b7dfb3c37 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -54,7 +54,7 @@ class Map { /* 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(); diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm index fcdf12fcd54..48ec2d1c710 100644 --- a/ios/MBXViewController.mm +++ b/ios/MBXViewController.mm @@ -210,7 +210,7 @@ - (void)handleRotateGesture:(UIRotationGestureRecognizer *)rotate } 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); } } diff --git a/src/map/map.cpp b/src/map/map.cpp index 6ed3c0284ce..ab29425d935 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -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(); }