This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] #2805 - add sample tilt activity to test app
- Loading branch information
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...id/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.mapbox.mapboxsdk.testapp; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.mapbox.mapboxsdk.camera.CameraPosition; | ||
import com.mapbox.mapboxsdk.constants.Style; | ||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
import com.mapbox.mapboxsdk.utils.ApiAccess; | ||
import com.mapbox.mapboxsdk.views.MapView; | ||
|
||
public class TiltActivity extends AppCompatActivity { | ||
|
||
private MapView mMapView = null; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_tilt); | ||
|
||
// Target | ||
LatLng nyc = new LatLng(40.73581, -73.99155); | ||
|
||
// Set up the map | ||
mMapView = (MapView) findViewById(R.id.tiltMapView); | ||
mMapView.setAccessToken(ApiAccess.getToken(this)); | ||
mMapView.setStyleUrl(Style.MAPBOX_STREETS); | ||
mMapView.setCenterCoordinate(nyc); | ||
mMapView.setZoomLevel(11); | ||
mMapView.onCreate(savedInstanceState); | ||
|
||
/* | ||
* 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(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 | ||
protected void onStart() { | ||
super.onStart(); | ||
mMapView.onStart(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
mMapView.onStop(); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
mMapView.onPause(); | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
mMapView.onResume(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
mMapView.onDestroy(); | ||
} | ||
|
||
@Override | ||
protected void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
mMapView.onSaveInstanceState(outState); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.mapbox.mapboxsdk.testapp.TiltActivity"> | ||
|
||
<com.mapbox.mapboxsdk.views.MapView | ||
android:id="@+id/tiltMapView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters