Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #2805 - Setting TiltActivity to test setPitch() directly. A…
Browse files Browse the repository at this point in the history
…dding FloatRange annotations to setTilt() and tilt() methods.
  • Loading branch information
bleege committed Dec 3, 2015
1 parent f22c5f1 commit 4567d7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 {
Expand Down Expand Up @@ -146,6 +147,7 @@ public Builder target(LatLng location) {
* @param tilt Tilt value
* @return Builder
*/
@FloatRange(from = 0.0, to = 60.0)
public Builder tilt(float tilt) {
this.tilt = tilt;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,7 @@ public double getTilt() {
* 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -33,31 +34,37 @@ protected void onCreate(Bundle savedInstanceState) {
// 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
.build(); // Creates a CameraPosition from the builder
// Triggers tilt
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
*/
}

@Override
Expand Down

0 comments on commit 4567d7d

Please sign in to comment.