[Qt] Implement QMapboxGL::jumpTo
This commit is contained in:
committed by
Thiago Marcos P. Santos
parent
459e72d72a
commit
fa6421a56f
@@ -7,6 +7,7 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/sprite/sprite_image.hpp>
|
||||
#include <mbgl/storage/network_status.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
|
||||
@@ -209,6 +210,32 @@ void QMapboxGL::setCoordinateZoom(const Coordinate &coordinate_, double zoom_)
|
||||
mbgl::LatLng { coordinate_.first, coordinate_.second }, zoom_, d_ptr->margins);
|
||||
}
|
||||
|
||||
void QMapboxGL::jumpTo(const CameraOptions& camera)
|
||||
{
|
||||
mbgl::CameraOptions mbglCamera;
|
||||
if (camera.center.isValid()) {
|
||||
const Coordinate center = camera.center.value<Coordinate>();
|
||||
mbglCamera.center = mbgl::LatLng { center.first, center.second };
|
||||
}
|
||||
if (camera.anchor.isValid()) {
|
||||
const QPointF anchor = camera.anchor.value<QPointF>();
|
||||
mbglCamera.anchor = mbgl::ScreenCoordinate { anchor.x(), anchor.y() };
|
||||
}
|
||||
if (camera.zoom.isValid()) {
|
||||
mbglCamera.zoom = camera.zoom.value<double>();
|
||||
}
|
||||
if (camera.angle.isValid()) {
|
||||
mbglCamera.angle = -camera.angle.value<double>() * mbgl::util::DEG2RAD;
|
||||
}
|
||||
if (camera.pitch.isValid()) {
|
||||
mbglCamera.pitch = camera.pitch.value<double>() * mbgl::util::DEG2RAD;
|
||||
}
|
||||
|
||||
mbglCamera.padding = d_ptr->margins;
|
||||
|
||||
d_ptr->mapObj->jumpTo(mbglCamera);
|
||||
}
|
||||
|
||||
double QMapboxGL::bearing() const
|
||||
{
|
||||
return d_ptr->mapObj->getBearing();
|
||||
|
||||
Reference in New Issue
Block a user