[core] add setMaxZoom, setMinZoom
also change the default maxZoom to 20 to match -js.
This commit is contained in:
@@ -116,7 +116,9 @@ public:
|
||||
CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&);
|
||||
CameraOptions cameraForLatLngs(const std::vector<LatLng>&, const EdgeInsets&);
|
||||
void resetZoom();
|
||||
void setMinZoom(const double minZoom);
|
||||
double getMinZoom() const;
|
||||
void setMaxZoom(const double maxZoom);
|
||||
double getMaxZoom() const;
|
||||
|
||||
// Rotation
|
||||
|
||||
@@ -303,10 +303,24 @@ void Map::resetZoom() {
|
||||
setZoom(0);
|
||||
}
|
||||
|
||||
void Map::setMinZoom(const double minZoom) {
|
||||
transform->setMinZoom(minZoom);
|
||||
if (getZoom() < minZoom) {
|
||||
setZoom(minZoom);
|
||||
}
|
||||
}
|
||||
|
||||
double Map::getMinZoom() const {
|
||||
return transform->getState().getMinZoom();
|
||||
}
|
||||
|
||||
void Map::setMaxZoom(const double maxZoom) {
|
||||
transform->setMaxZoom(maxZoom);
|
||||
if (getZoom() > maxZoom) {
|
||||
setZoom(maxZoom);
|
||||
}
|
||||
}
|
||||
|
||||
double Map::getMaxZoom() const {
|
||||
return transform->getState().getMaxZoom();
|
||||
}
|
||||
|
||||
@@ -465,6 +465,14 @@ void Transform::setScale(double scale, const EdgeInsets& padding, const Duration
|
||||
setScale(scale, center, duration);
|
||||
}
|
||||
|
||||
void Transform::setMinZoom(const double minZoom) {
|
||||
state.setMinZoom(minZoom);
|
||||
}
|
||||
|
||||
void Transform::setMaxZoom(const double maxZoom) {
|
||||
state.setMaxZoom(maxZoom);
|
||||
}
|
||||
|
||||
#pragma mark - Angle
|
||||
|
||||
void Transform::rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& duration) {
|
||||
|
||||
@@ -79,6 +79,9 @@ public:
|
||||
/** Returns the scale factor. */
|
||||
double getScale() const;
|
||||
|
||||
void setMinZoom(const double minZoom);
|
||||
void setMaxZoom(const double maxZoom);
|
||||
|
||||
// Angle
|
||||
|
||||
void rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& = Duration::zero());
|
||||
|
||||
@@ -168,6 +168,10 @@ double TransformState::getScale() const {
|
||||
return scale;
|
||||
}
|
||||
|
||||
void TransformState::setMinZoom(const double minZoom) {
|
||||
min_scale = zoomScale(minZoom);
|
||||
}
|
||||
|
||||
double TransformState::getMinZoom() const {
|
||||
double test_scale = min_scale;
|
||||
double unused_x = x;
|
||||
@@ -177,6 +181,10 @@ double TransformState::getMinZoom() const {
|
||||
return scaleZoom(test_scale);
|
||||
}
|
||||
|
||||
void TransformState::setMaxZoom(const double maxZoom) {
|
||||
max_scale = zoomScale(maxZoom);
|
||||
}
|
||||
|
||||
double TransformState::getMaxZoom() const {
|
||||
return scaleZoom(max_scale);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ public:
|
||||
int32_t getIntegerZoom() const;
|
||||
double getZoomFraction() const;
|
||||
double getScale() const;
|
||||
void setMinZoom(const double minZoom);
|
||||
double getMinZoom() const;
|
||||
void setMaxZoom(const double maxZoom);
|
||||
double getMaxZoom() const;
|
||||
|
||||
// Rotation
|
||||
@@ -83,7 +85,7 @@ private:
|
||||
|
||||
// Limit the amount of zooming possible on the map.
|
||||
double min_scale = std::pow(2, 0);
|
||||
double max_scale = std::pow(2, 18);
|
||||
double max_scale = std::pow(2, 20);
|
||||
|
||||
NorthOrientation orientation = NorthOrientation::Upwards;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user