QVariant cameraInterpolator(const QGeoCameraData &start, const QGeoCameraData &end, qreal progress) { QGeoCameraData result = start; QGeoCoordinate from = start.center(); QGeoCoordinate to = end.center(); if (from == to) { if (progress < 0.5) { result.setCenter(from); } else { result.setCenter(to); } } else { QGeoCoordinate coordinateResult = QGeoProjection::coordinateInterpolation(from, to, progress); result.setCenter(coordinateResult); } double sf = 1.0 - progress; double ef = progress; result.setBearing(sf * start.bearing() + ef * end.bearing()); result.setTilt(sf * start.tilt() + ef * end.tilt()); result.setRoll(sf * start.roll() + ef * end.roll()); result.setZoomLevel(sf * start.zoomLevel() + ef * end.zoomLevel()); return QVariant::fromValue(result); }
void QGeoMapController::setCenter(const QGeoCoordinate ¢er) { QGeoCameraData cd = map_->cameraData(); if (center == cd.center()) return; cd.setCenter(center); map_->setCameraData(cd); }
void QGeoMapController::setLatitude(qreal latitude) { QGeoCameraData cd = map_->cameraData(); if (latitude == cd.center().latitude()) return; QGeoCoordinate coord(latitude, cd.center().longitude(), cd.center().altitude()); cd.setCenter(coord); map_->setCameraData(cd); }
void QGeoMapController::pan(qreal dx, qreal dy) { if (dx == 0 && dy == 0) return; QGeoCameraData cd = map_->cameraData(); QGeoCoordinate coord = map_->itemPositionToCoordinate( QDoubleVector2D(map_->width() / 2 + dx, map_->height() / 2 + dy)); // keep altitude as it was coord.setAltitude(cd.center().altitude()); if (coord.isValid()) { cd.setCenter(coord); map_->setCameraData(cd); } }