[android] #3358 - Making Core GL camera methods private. Adding moveCamera() API method. Updating CameraActivity to use only animateCamera() and moveCamera() API.
This commit is contained in:
@@ -1521,7 +1521,7 @@ public final class MapView extends FrameLayout {
|
||||
public final void animateCamera (CameraUpdate update, int durationMs, final MapView.CancelableCallback callback) {
|
||||
|
||||
if (update.getTarget() == null) {
|
||||
Log.w(TAG, "animateCamera with null target coordinate passed in. Will immediatele return without animating camera.");
|
||||
Log.w(TAG, "animateCamera with null target coordinate passed in. Will immediately return without animating camera.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1565,8 +1565,8 @@ public final class MapView extends FrameLayout {
|
||||
|
||||
if (durationMs == 0) {
|
||||
// Route To `jumpTo`
|
||||
Log.i(TAG, "jumpTo() called with angle = " + angle + "; target = " + update.getTarget() + "; durationNano = " + durationNano + "; Pitch = " + pitch + "; Zoom = " + update.getZoom());
|
||||
jumpTo(angle, update.getTarget(), pitch, zoom);
|
||||
Log.i(TAG, "easeTo() called with angle = " + angle + "; target = " + update.getTarget() + "; durationNano = " + durationNano + "; Pitch = " + pitch + "; Zoom = " + update.getZoom());
|
||||
easeTo(angle, update.getTarget(), 0, pitch, zoom);
|
||||
} else {
|
||||
// Use `flyTo`
|
||||
Log.i(TAG, "flyTo() called with angle = " + angle + "; target = " + update.getTarget() + "; durationNano = " + durationNano + "; Pitch = " + pitch + "; Zoom = " + update.getZoom());
|
||||
@@ -1574,6 +1574,38 @@ public final class MapView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repositions the camera according to the instructions defined in the update.
|
||||
* The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position.
|
||||
* See CameraUpdateFactory for a set of updates.
|
||||
* @param update The change that should be applied to the camera.
|
||||
*/
|
||||
public final void moveCamera (CameraUpdate update) {
|
||||
if (update.getTarget() == null) {
|
||||
Log.w(TAG, "moveCamera with null target coordinate passed in. Will immediately return without moving camera.");
|
||||
return;
|
||||
}
|
||||
|
||||
mNativeMapView.cancelTransitions();
|
||||
|
||||
// Convert Degrees To Radians
|
||||
double angle = -1;
|
||||
if (update.getBearing() >= 0) {
|
||||
angle = (-update.getBearing()) * MathConstants.DEG2RAD;
|
||||
}
|
||||
double pitch = -1;
|
||||
if (update.getTilt() >= 0) {
|
||||
double dp = MathUtils.clamp(update.getTilt(), MINIMUM_TILT, MAXIMUM_TILT);
|
||||
pitch = dp * MathConstants.DEG2RAD;
|
||||
}
|
||||
double zoom = -1;
|
||||
if (update.getZoom() >= 0) {
|
||||
zoom = update.getZoom();
|
||||
}
|
||||
|
||||
jumpTo(angle, update.getTarget(), pitch, zoom);
|
||||
}
|
||||
|
||||
//
|
||||
// InfoWindows
|
||||
//
|
||||
@@ -2411,7 +2443,7 @@ public final class MapView extends FrameLayout {
|
||||
* @param zoom Zoom Level
|
||||
*/
|
||||
@UiThread
|
||||
public void jumpTo(double bearing, LatLng center, double pitch, double zoom) {
|
||||
private void jumpTo(double bearing, LatLng center, double pitch, double zoom) {
|
||||
mNativeMapView.jumpTo(bearing, center, pitch, zoom);
|
||||
}
|
||||
|
||||
@@ -2426,7 +2458,7 @@ public final class MapView extends FrameLayout {
|
||||
* @param zoom Zoom Level
|
||||
*/
|
||||
@UiThread
|
||||
public void easeTo(double bearing, LatLng center, long duration, double pitch, double zoom) {
|
||||
private void easeTo(double bearing, LatLng center, long duration, double pitch, double zoom) {
|
||||
mNativeMapView.easeTo(bearing, center, duration, pitch, zoom);
|
||||
}
|
||||
|
||||
@@ -2439,7 +2471,7 @@ public final class MapView extends FrameLayout {
|
||||
* @param zoom Zoom Level
|
||||
*/
|
||||
@UiThread
|
||||
public void flyTo(double bearing, LatLng center, long duration, double pitch, double zoom) {
|
||||
private void flyTo(double bearing, LatLng center, long duration, double pitch, double zoom) {
|
||||
mNativeMapView.flyTo(bearing, center, duration, pitch, zoom);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CameraActivity extends AppCompatActivity {
|
||||
mMapView.setCompassEnabled(true);
|
||||
mMapView.onCreate(savedInstanceState);
|
||||
|
||||
Button cameraButton = (Button) findViewById(R.id.cameraAnimateButton);
|
||||
Button cameraButton = (Button) findViewById(R.id.cameraMoveButton);
|
||||
cameraButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -52,11 +52,11 @@ public class CameraActivity extends AppCompatActivity {
|
||||
.zoom(14) // Sets the zoom
|
||||
.tilt(30) // Sets the tilt of the camera to 30 degrees
|
||||
.build(); // Creates a CameraPosition from the builder
|
||||
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
mMapView.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
});
|
||||
|
||||
Button cameraCallbackButton = (Button) findViewById(R.id.cameraAnimateCallbackButton);
|
||||
Button cameraCallbackButton = (Button) findViewById(R.id.cameraEaseButton);
|
||||
cameraCallbackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -67,27 +67,11 @@ public class CameraActivity extends AppCompatActivity {
|
||||
.bearing(180) // Sets the orientation of the camera to south
|
||||
.build(); // Creates a CameraPosition from the builder
|
||||
|
||||
MapView.CancelableCallback callback = new MapView.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// NOTE: This shouldn't appear
|
||||
Log.i(TAG, "onCancel Callback called.");
|
||||
Toast.makeText(CameraActivity.this, "onCancel Callback called.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Log.i(TAG, "onFinish Callback called.");
|
||||
Toast.makeText(CameraActivity.this, "onFinish Callback called.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
|
||||
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), callback);
|
||||
|
||||
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
});
|
||||
|
||||
Button cameraDurationButton = (Button) findViewById(R.id.cameraAnimateDurationButton);
|
||||
Button cameraDurationButton = (Button) findViewById(R.id.cameraAnimateButton);
|
||||
cameraDurationButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_camera_animate"
|
||||
android:id="@+id/cameraAnimateButton"
|
||||
android:text="@string/button_camera_move"
|
||||
android:id="@+id/cameraMoveButton"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
@@ -32,18 +32,18 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_camera_animate_callback"
|
||||
android:id="@+id/cameraAnimateCallbackButton"
|
||||
android:layout_alignTop="@+id/cameraAnimateButton"
|
||||
android:text="@string/button_camera_ease"
|
||||
android:id="@+id/cameraEaseButton"
|
||||
android:layout_alignTop="@+id/cameraMoveButton"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@color/white"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_camera_animate_duration"
|
||||
android:id="@+id/cameraAnimateDurationButton"
|
||||
android:layout_alignBottom="@+id/cameraAnimateCallbackButton"
|
||||
android:text="@string/button_camera_animate"
|
||||
android:id="@+id/cameraAnimateButton"
|
||||
android:layout_alignBottom="@+id/cameraEaseButton"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="@dimen/fab_margin"
|
||||
android:background="@color/white"/>
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
<string name="action_visible_bounds_explanation">Center map around 2 markers</string>
|
||||
<string name="action_remove_polylines">Remove polylines</string>
|
||||
|
||||
<string name="button_camera_move">Move</string>
|
||||
<string name="button_camera_ease">Ease</string>
|
||||
<string name="button_camera_animate">Animate</string>
|
||||
<string name="button_camera_animate_callback">Callback</string>
|
||||
<string name="button_camera_animate_duration">Duration</string>
|
||||
|
||||
<string name="label_fps">FPS:</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user