[android] - fix inconsistency of float usage in CameraPosition and CameraUpdateFactory (#6941)
This commit is contained in:
@@ -42,12 +42,12 @@ public final class CameraPosition implements Parcelable {
|
||||
public final LatLng target;
|
||||
|
||||
/**
|
||||
* The angle, in degrees, of the camera angle from the nadir (directly facing the Earth). See tilt(float) for details of restrictions on the range of values.
|
||||
* The angle, in degrees, of the camera angle from the nadir (directly facing the Earth). See tilt(double) for details of restrictions on the range of values.
|
||||
*/
|
||||
public final double tilt;
|
||||
|
||||
/**
|
||||
* Zoom level near the center of the screen. See zoom(float) for the definition of the camera's zoom level.
|
||||
* Zoom level near the center of the screen. See zoom(double) for the definition of the camera's zoom level.
|
||||
*/
|
||||
public final double zoom;
|
||||
|
||||
@@ -55,8 +55,8 @@ public final class CameraPosition implements Parcelable {
|
||||
* Constructs a CameraPosition.
|
||||
*
|
||||
* @param target The target location to align with the center of the screen.
|
||||
* @param zoom Zoom level at target. See zoom(float) for details of restrictions.
|
||||
* @param tilt The camera angle, in degrees, from the nadir (directly down). See tilt(float) for details of restrictions.
|
||||
* @param zoom Zoom level at target. See zoom(double) for details of restrictions.
|
||||
* @param tilt The camera angle, in degrees, from the nadir (directly down). See tilt(double) for details of restrictions.
|
||||
* @param bearing Direction that the camera is pointing in, in degrees clockwise from north. This value will be normalized to be within 0 degrees inclusive and 360 degrees exclusive.
|
||||
* @throws NullPointerException if target is null
|
||||
* @throws IllegalArgumentException if tilt is outside the range of 0 to 90 degrees inclusive.
|
||||
@@ -206,7 +206,7 @@ public final class CameraPosition implements Parcelable {
|
||||
target(new LatLng(nativeCameraValues[0], nativeCameraValues[1]));
|
||||
bearing(convertNativeBearing(nativeCameraValues[2]));
|
||||
tilt(nativeCameraValues[3]);
|
||||
zoom((float) nativeCameraValues[4]);
|
||||
zoom(nativeCameraValues[4]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public final class CameraPosition implements Parcelable {
|
||||
* @return Builder
|
||||
*/
|
||||
public Builder tilt(double tilt) {
|
||||
this.tilt = (float) MathUtils.clamp(tilt, MapboxConstants.MINIMUM_TILT, MapboxConstants.MAXIMUM_TILT);
|
||||
this.tilt = MathUtils.clamp(tilt, MapboxConstants.MINIMUM_TILT, MapboxConstants.MAXIMUM_TILT);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class CameraUpdateFactory {
|
||||
* @param zoom Zoom level to change to
|
||||
* @return CameraUpdate Final Camera Position
|
||||
*/
|
||||
public static CameraUpdate newLatLngZoom(@NonNull LatLng latLng, float zoom) {
|
||||
public static CameraUpdate newLatLngZoom(@NonNull LatLng latLng, double zoom) {
|
||||
return new CameraPositionUpdate(-1, latLng, -1, zoom);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public final class CameraUpdateFactory {
|
||||
* @param focus Focus point of zoom
|
||||
* @return CameraUpdate Final Camera Position
|
||||
*/
|
||||
public static CameraUpdate zoomBy(float amount, Point focus) {
|
||||
public static CameraUpdate zoomBy(double amount, Point focus) {
|
||||
return new ZoomUpdate(amount, focus.x, focus.y);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class CameraUpdateFactory {
|
||||
* @param amount Amount of zoom level to change with
|
||||
* @return CameraUpdate Final Camera Position
|
||||
*/
|
||||
public static CameraUpdate zoomBy(float amount) {
|
||||
public static CameraUpdate zoomBy(double amount) {
|
||||
return new ZoomUpdate(ZoomUpdate.ZOOM_BY, amount);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public final class CameraUpdateFactory {
|
||||
* @param zoom Zoom level to change to
|
||||
* @return CameraUpdate Final Camera Position
|
||||
*/
|
||||
public static CameraUpdate zoomTo(float zoom) {
|
||||
public static CameraUpdate zoomTo(double zoom) {
|
||||
return new ZoomUpdate(ZoomUpdate.ZOOM_TO, zoom);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ public final class CameraUpdateFactory {
|
||||
float scaleY = (uiSettings.getHeight() - padding.top - padding.bottom) / height;
|
||||
minScale = scaleX < scaleY ? scaleX : scaleY;
|
||||
zoom = projection.calculateZoom(minScale);
|
||||
zoom = MathUtils.clamp(zoom, (float) mapboxMap.getMinZoom(), (float) mapboxMap.getMaxZoom());
|
||||
zoom = MathUtils.clamp(zoom, mapboxMap.getMinZoom(), mapboxMap.getMaxZoom());
|
||||
}
|
||||
|
||||
// Calculate the center point
|
||||
@@ -271,7 +271,7 @@ public final class CameraUpdateFactory {
|
||||
|
||||
return new CameraPosition.Builder()
|
||||
.target(center)
|
||||
.zoom((float) zoom)
|
||||
.zoom(zoom)
|
||||
.tilt(0)
|
||||
.bearing(0)
|
||||
.build();
|
||||
@@ -335,12 +335,12 @@ public final class CameraUpdateFactory {
|
||||
this.zoom = 0;
|
||||
}
|
||||
|
||||
ZoomUpdate(@Type int type, float zoom) {
|
||||
ZoomUpdate(@Type int type, double zoom) {
|
||||
this.type = type;
|
||||
this.zoom = zoom;
|
||||
}
|
||||
|
||||
ZoomUpdate(float zoom, float x, float y) {
|
||||
ZoomUpdate(double zoom, float x, float y) {
|
||||
this.type = ZOOM_TO_POINT;
|
||||
this.zoom = zoom;
|
||||
this.x = x;
|
||||
|
||||
@@ -1284,7 +1284,7 @@ public class MapView extends FrameLayout {
|
||||
return direction;
|
||||
}
|
||||
|
||||
void setBearing(float bearing) {
|
||||
void setBearing(double bearing) {
|
||||
if (destroyed) {
|
||||
return;
|
||||
}
|
||||
@@ -1292,7 +1292,7 @@ public class MapView extends FrameLayout {
|
||||
nativeMapView.setBearing(bearing);
|
||||
}
|
||||
|
||||
void setBearing(float bearing, long duration) {
|
||||
void setBearing(double bearing, long duration) {
|
||||
if (destroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public class MyLocationView extends View {
|
||||
private PointF screenLocation;
|
||||
|
||||
// camera vars
|
||||
private float bearing;
|
||||
private float tilt;
|
||||
private double bearing;
|
||||
private double tilt;
|
||||
|
||||
// Controls the compass update rate in milliseconds
|
||||
private static final int COMPASS_UPDATE_RATE_MS = 500;
|
||||
@@ -266,7 +266,7 @@ public class MyLocationView extends View {
|
||||
|
||||
// put camera in position
|
||||
camera.save();
|
||||
camera.rotate(tilt, 0, 0);
|
||||
camera.rotate((float) tilt, 0, 0);
|
||||
camera.getMatrix(matrix);
|
||||
|
||||
if (myBearingTrackingMode != MyBearingTracking.NONE && directionAnimator != null) {
|
||||
@@ -306,14 +306,14 @@ public class MyLocationView extends View {
|
||||
}
|
||||
|
||||
public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) {
|
||||
this.tilt = (float) tilt;
|
||||
this.tilt = tilt;
|
||||
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
|
||||
mapboxMap.getUiSettings().setFocalPoint(new PointF(getCenterX(), getCenterY()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setBearing(double bearing) {
|
||||
this.bearing = (float) bearing;
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public void setCameraPosition(CameraPosition position) {
|
||||
@@ -385,7 +385,7 @@ public class MyLocationView extends View {
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("superState", super.onSaveInstanceState());
|
||||
bundle.putFloat("tilt", tilt);
|
||||
bundle.putDouble("tilt", tilt);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ public class MyLocationView extends View {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void setCompass(float bearing) {
|
||||
private void setCompass(double bearing) {
|
||||
float oldDir = previousDirection;
|
||||
if (directionAnimator != null) {
|
||||
oldDir = (Float) directionAnimator.getAnimatedValue();
|
||||
@@ -483,7 +483,7 @@ public class MyLocationView extends View {
|
||||
directionAnimator = null;
|
||||
}
|
||||
|
||||
float newDir = bearing;
|
||||
float newDir = (float) bearing;
|
||||
float diff = oldDir - newDir;
|
||||
if (diff > 180.0f) {
|
||||
newDir += 360.0f;
|
||||
|
||||
Reference in New Issue
Block a user