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

Commit

Permalink
[android] #3244 - Reordering animateCamera() set data calls and makin…
Browse files Browse the repository at this point in the history
…g zoom level of CameraActivity a bit more obvious
  • Loading branch information
bleege committed Dec 11, 2015
1 parent 3ef877d commit 8f6d08a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1448,10 +1448,10 @@ public final CameraPosition getCameraPosition () {
*/
public final void animateCamera (CameraUpdate update) {

setBearing(update.getBearing());
setTilt(new Double(update.getTilt()), 0L);
setCenterCoordinate(update.getTarget());
setZoomLevel(update.getZoom());
setTilt(new Double(update.getTilt()), 0L);
setBearing(update.getBearing());

}

Expand Down Expand Up @@ -2483,6 +2483,12 @@ void setBearing(float bearing) {
mNativeMapView.setBearing(bearing, 100);
}

/*
public void setBearing(float bearing) {
mNativeMapView.setBearing(bearing);
}
*/

//
// View events
//
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.view.MenuItem;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.Style;
Expand Down Expand Up @@ -32,6 +33,7 @@ protected void onCreate(Bundle savedInstanceState) {
mMapView = (MapView) findViewById(R.id.cameraMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.setStyle(Style.MAPBOX_STREETS);
mMapView.setCompassEnabled(true);
mMapView.onCreate(savedInstanceState);
}

Expand All @@ -49,7 +51,7 @@ public void onResume() {

CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(44.50128, -88.06216)) // Sets the center of the map to Mountain View
.zoom(17) // Sets the zoom
.zoom(14) // 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
Expand Down Expand Up @@ -85,4 +87,15 @@ public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

0 comments on commit 8f6d08a

Please sign in to comment.