summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorAntonio Zugaldia <antonio@mapbox.com>2015-12-01 16:01:32 -0500
committerBrad Leege <bleege@gmail.com>2015-12-03 16:57:42 -0600
commit759e67b70d4bad8794c7b627f46cd660299c0271 (patch)
tree0981dcc1aa0b3ca7cab6812c9ddca4225ff3bc77 /android
parent6e77c4be82ff5cc62d631ebd19934e64bd1c3a04 (diff)
downloadqtlocation-mapboxgl-759e67b70d4bad8794c7b627f46cd660299c0271.tar.gz
[android] #2805 - add sample tilt activity to test app
Diffstat (limited to 'android')
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml3
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java4
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java85
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml13
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml6
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml2
6 files changed, 113 insertions, 0 deletions
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index e600ef3b5c..de5f3a2aa5 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -39,6 +39,9 @@
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" />
<activity
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
index 570c85342e..17af8fe2db 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
@@ -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;
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java
new file mode 100644
index 0000000000..5ff29fe228
--- /dev/null
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/TiltActivity.java
@@ -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);
+ }
+
+}
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml b/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml
new file mode 100644
index 0000000000..2e27fbf073
--- /dev/null
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_tilt.xml
@@ -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>
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
index 69c3f7e593..f8bf152a5d 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
@@ -67,6 +67,12 @@
<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"
android:icon="@drawable/ic_now_widgets_24dp"
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
index 62390414ba..2ac09d96b6 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
@@ -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>