diff options
author | Romain Quidet <contact@xdappfactory.com> | 2019-12-12 14:31:24 +0100 |
---|---|---|
committer | Aleksandar Stojiljković <aleksandar.stojiljkovic@mapbox.com> | 2019-12-17 16:19:33 +0200 |
commit | 5693f3be02a10071d186f33d069ea5b796f427d5 (patch) | |
tree | c96b9cf1eea6529c5df2e4d07c2f3ac66de94508 /src/mbgl/map | |
parent | 9d758564bed983625f69e4b0361f5156df9b11b5 (diff) | |
download | qtlocation-mapboxgl-5693f3be02a10071d186f33d069ea5b796f427d5.tar.gz |
correct insets camera management - see https://github.com/mapbox/mapbox-gl-native-ios/issues/59
Diffstat (limited to 'src/mbgl/map')
-rw-r--r-- | src/mbgl/map/map.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 2e585c3eff..cb31d434fa 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -182,13 +182,12 @@ CameraOptions cameraForLatLngs(const std::vector<LatLng>& latLngs, const Transfo // Calculate the bounds of the possibly rotated shape with respect to the viewport. ScreenCoordinate nePixel = {-INFINITY, -INFINITY}; ScreenCoordinate swPixel = {INFINITY, INFINITY}; - double viewportHeight = size.height; for (LatLng latLng : latLngs) { ScreenCoordinate pixel = transform.latLngToScreenCoordinate(latLng); swPixel.x = std::min(swPixel.x, pixel.x); nePixel.x = std::max(nePixel.x, pixel.x); - swPixel.y = std::min(swPixel.y, viewportHeight - pixel.y); - nePixel.y = std::max(nePixel.y, viewportHeight - pixel.y); + swPixel.y = std::min(swPixel.y, pixel.y); + nePixel.y = std::max(nePixel.y, pixel.y); } double width = nePixel.x - swPixel.x; double height = nePixel.y - swPixel.y; @@ -212,21 +211,9 @@ CameraOptions cameraForLatLngs(const std::vector<LatLng>& latLngs, const Transfo // Calculate the center point of a virtual bounds that is extended in all directions by padding. ScreenCoordinate centerPixel = nePixel + swPixel; - ScreenCoordinate paddedNEPixel = { - padding.right() / minScale, - padding.top() / minScale, - }; - ScreenCoordinate paddedSWPixel = { - padding.left() / minScale, - padding.bottom() / minScale, - }; - centerPixel = centerPixel + paddedNEPixel - paddedSWPixel; centerPixel /= 2.0; - // CameraOptions origin is at the top-left corner. - centerPixel.y = viewportHeight - centerPixel.y; - - return CameraOptions().withCenter(transform.screenCoordinateToLatLng(centerPixel)).withZoom(zoom); + return CameraOptions().withCenter(transform.screenCoordinateToLatLng(centerPixel)).withPadding(padding).withZoom(zoom); } CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const EdgeInsets& padding, optional<double> bearing, optional<double> pitch) const { |