[android] #2805 - add sample tilt activity to test app
This commit is contained in:
committed by
Brad Leege
parent
6e77c4be82
commit
759e67b70d
@@ -38,6 +38,9 @@
|
||||
android:name=".BulkMarkerActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/action_add_bulk_markers" />
|
||||
<activity
|
||||
android:name=".TiltActivity"
|
||||
android:label="@string/activity_tilt" />
|
||||
<activity
|
||||
android:name=".MapFragmentActivity"
|
||||
android:label="@string/activity_map_fragment" />
|
||||
|
||||
@@ -341,6 +341,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(new Intent(getApplicationContext(), InfoWindowAdapterActivity.class));
|
||||
return true;
|
||||
|
||||
case R.id.action_tilt:
|
||||
startActivity(new Intent(getApplicationContext(), TiltActivity.class));
|
||||
return true;
|
||||
|
||||
case R.id.action_map_fragment:
|
||||
startActivity(new Intent(getApplicationContext(), MapFragmentActivity.class));
|
||||
return true;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
@@ -66,6 +66,12 @@
|
||||
android:title="@string/navdrawer_menu_title_individual_tests">
|
||||
<menu>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_tilt"
|
||||
android:checkable="false"
|
||||
android:icon="@drawable/ic_flip_to_back_24dp"
|
||||
android:title="@string/action_tilt" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_map_fragment"
|
||||
android:checkable="false"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<string name="app_name">Mapbox GL</string>
|
||||
|
||||
<!-- Test Activities -->
|
||||
<string name="activity_tilt">Map Tilt</string>
|
||||
<string name="activity_infowindow_adapter">InfoWindow Adapter</string>
|
||||
<string name="activity_map_fragment">Map Fragment Activity</string>
|
||||
<string name="activity_press_for_marker">Press For Marker Activity</string>
|
||||
@@ -24,6 +25,7 @@
|
||||
<string name="action_debug">Cycle map debug options</string>
|
||||
<string name="action_point_annotations">Toggle point annotations</string>
|
||||
<string name="action_info_window_adapter">InfoWindow Adapter</string>
|
||||
<string name="action_tilt">Tilt</string>
|
||||
<string name="action_map_fragment">MapFragment</string>
|
||||
<string name="action_press_for_marker">Press For Marker</string>
|
||||
<string name="action_manual_zoom">Manual Zoom</string>
|
||||
|
||||
Reference in New Issue
Block a user