[android] #2805 - Setting TiltActivity to test setPitch() directly. Adding FloatRange annotations to setTilt() and tilt() methods.

This commit is contained in:
Brad Leege
2015-12-03 13:27:04 -06:00
parent 5024d45c63
commit 4dd84b3d92
3 changed files with 13 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.camera;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.FloatRange;
import com.mapbox.mapboxsdk.geometry.LatLng;
public final class CameraPosition implements Parcelable {
@@ -146,6 +147,7 @@ public final class CameraPosition implements Parcelable {
* @param tilt Tilt value
* @return Builder
*/
@FloatRange(from = 0.0, to = 60.0)
public Builder tilt(float tilt) {
this.tilt = tilt;
return this;

View File

@@ -1118,6 +1118,7 @@ public final class MapView extends FrameLayout {
* Sets the Tilt in degrees of the MapView
* @param pitch New tilt in degrees
*/
@FloatRange(from = 0.0, to = 60.0)
public void setTilt(double pitch) {
mNativeMapView.setPitch(pitch);
}

View File

@@ -4,6 +4,7 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
@@ -33,24 +34,29 @@ public class TiltActivity extends AppCompatActivity {
// Target
LatLng dc = new LatLng(38.90252, -77.02291);
LatLng nyc = new LatLng(40.73581, -73.99155);
LatLng target = nyc;
// Set up the map
mMapView = (MapView) findViewById(R.id.tiltMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.setStyleUrl(Style.MAPBOX_STREETS);
mMapView.setCenterCoordinate(target);
// Initialize map to Washington, DC and different zoom level so that it's obvious that animateCamera works
mMapView.setCenterCoordinate(dc);
mMapView.setZoomLevel(11);
mMapView.onCreate(savedInstanceState);
Log.i(TiltActivity.class.getCanonicalName(), "Original Tilt = " + mMapView.getTilt());
mMapView.setTilt(45);
Log.i(TiltActivity.class.getCanonicalName(), "Changed Tilt = " + mMapView.getTilt());
/*
* Our tilt API follows Google's Android API:
* https://developers.google.com/maps/documentation/android-api/views#updating_the_camera_view
*/
/*
// Construct a CameraPosition focusing on target and animate the camera to that position.
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(target) // Sets the center of the map to target
.target(nyc) // Sets the center of the map to target
.zoom(17) // Sets the zoom
.bearing(90) // Sets the orientation of the camera to east
.tilt(30) // Sets the tilt of the camera to 30 degrees
@@ -58,6 +64,7 @@ public class TiltActivity extends AppCompatActivity {
// Triggers tilt
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
*/
}
@Override