diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-24 17:31:13 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-27 21:38:36 +0200 |
commit | f772a6392db1f24a8fbfd0a120de87fd96e51921 (patch) | |
tree | fbc6021b9ea61722c0cbb45183a18c92f49e708d /platform/glfw | |
parent | 20ca1a041868955524b3f2475ebc83760398ca82 (diff) | |
download | qtlocation-mapboxgl-f772a6392db1f24a8fbfd0a120de87fd96e51921.tar.gz |
[glfw] Use jumpTo() in the route demo
Diffstat (limited to 'platform/glfw')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 9179113139..d0c8a7be76 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -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; |