Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[glfw] Use jumpTo() in the route demo
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Nov 27, 2018
1 parent 1b46099 commit 34e72c8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions platform/glfw/glfw_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,18 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
static double routeDistance = ruler.lineDistance(lineString);
static double routeProgress = 0;
routeProgress += 0.0005;
if (routeProgress > 1.0) routeProgress = 0;
if (routeProgress > 1.0) {
routeProgress = 0.0;
}

double distance = routeProgress * routeDistance;
auto point = ruler.along(lineString, distance);
auto point = ruler.along(lineString, routeProgress * routeDistance);
const mbgl::LatLng center { point.y, point.x };
auto latLng = routeMap->getLatLng();
routeMap->setLatLng({ point.y, point.x });
double bearing = ruler.bearing({ latLng.longitude(), latLng.latitude() }, point);
double easing = bearing - routeMap->getBearing();
easing += easing > 180.0 ? -360.0 : easing < -180 ? 360.0 : 0;
routeMap->setBearing(routeMap->getBearing() + (easing / 20));
routeMap->setPitch(60.0);
routeMap->setZoom(18.0);
bearing = routeMap->getBearing() + (easing / 20);
routeMap->jumpTo(mbgl::CameraOptions().withCenter(center).withZoom(18.0).withAngle(bearing).withPitch(60.0));
};
view->animateRouteCallback(view->map);
} break;
Expand Down

0 comments on commit 34e72c8

Please sign in to comment.