summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2015-10-22 14:08:31 +0200
committerTobrun <tobrun.van.nuland@gmail.com>2015-10-22 16:51:05 +0200
commit17decd5c867d8c0aec675c5b45d1f1d152e0b9d0 (patch)
treef88149a1f1aff1e99d4b84e02120db28b77b28aa /android
parent19c58ec4988b109748bb25ffca49498f26e11547 (diff)
downloadqtlocation-mapboxgl-17decd5c867d8c0aec675c5b45d1f1d152e0b9d0.tar.gz
[android] #2716 - moved visible coordinate bounds to separate activity
Diffstat (limited to 'android')
-rw-r--r--android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml4
-rw-r--r--android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java7
-rw-r--r--android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivity.java116
-rw-r--r--android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml20
-rw-r--r--android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml2
5 files changed, 143 insertions, 6 deletions
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index c68e9c4e0e..b57b38fe64 100644
--- a/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -26,6 +26,10 @@
</activity>
<activity
+ android:name=".VisibleCoordinateBoundsActivity"
+ android:label="@string/activity_visible_coordinate_bounds" />
+
+ <activity
android:name=".InfoWindowAdapterActivity"
android:label="@string/activity_infowindow_adapter" />
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
index 8012c5201e..b01673699c 100644
--- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
+++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
@@ -4,7 +4,6 @@ import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
-import android.graphics.RectF;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
@@ -31,7 +30,6 @@ import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.annotations.Sprite;
import com.mapbox.mapboxsdk.constants.Style;
-import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
@@ -333,10 +331,7 @@ public class MainActivity extends AppCompatActivity {
return true;
case R.id.action_visible_bounds:
- // Set visible bounds to Moscone Center West (37.783703, -122.403589) and Union Square (37.7874436,-122.4072359)
- mMapView.setVisibleCoordinateBounds(
- new CoordinateBounds(new LatLng(37.783703, -122.403589), new LatLng(37.7874436,-122.4072359)),
- new RectF(100, 350, 100, 300), true);
+ startActivity(new Intent(getApplicationContext(), VisibleCoordinateBoundsActivity.class));
return true;
default:
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivity.java
new file mode 100644
index 0000000000..413acf9328
--- /dev/null
+++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivity.java
@@ -0,0 +1,116 @@
+package com.mapbox.mapboxsdk.testapp;
+
+import android.graphics.RectF;
+import android.os.Bundle;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+import android.view.View;
+
+import com.mapbox.mapboxsdk.annotations.MarkerOptions;
+import com.mapbox.mapboxsdk.constants.Style;
+import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.utils.ApiAccess;
+import com.mapbox.mapboxsdk.views.MapView;
+
+public class VisibleCoordinateBoundsActivity extends AppCompatActivity {
+
+ private MapView mMapView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_visible_bounds);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
+
+ mMapView = (MapView) findViewById(R.id.mapView);
+ mMapView.setAccessToken(ApiAccess.getToken(this));
+ mMapView.setStyle(Style.DARK);
+ mMapView.onCreate(savedInstanceState);
+
+ final LatLng losAngeles = new LatLng(34.053940, -118.242622);
+ final LatLng newYork = new LatLng(40.712730, -74.005953);
+
+ mMapView.addMarker(new MarkerOptions()
+ .title("Los Angeles")
+ .snippet("City Hall")
+ .position(losAngeles));
+
+ mMapView.addMarker(new MarkerOptions()
+ .title("New York")
+ .snippet("City Hall")
+ .position(newYork));
+
+ Snackbar.make(findViewById(android.R.id.content), R.string.action_visible_bounds_explanation, Snackbar.LENGTH_INDEFINITE)
+ .setAction(android.R.string.ok, new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mMapView.setVisibleCoordinateBounds(new CoordinateBounds(losAngeles, newYork), new RectF(200, 0, 200, 0), true);
+ }
+ }).show();
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mMapView.onStart();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mMapView.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mMapView.onPause();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mMapView.onStop();
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mMapView.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mMapView.onDestroy();
+ }
+
+ @Override
+ 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);
+ }
+ }
+}
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml
new file mode 100644
index 0000000000..5b5d5d2fa0
--- /dev/null
+++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@color/primary"
+ android:minHeight="?attr/actionBarSize"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+ <com.mapbox.mapboxsdk.views.MapView
+ android:id="@+id/mapView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+</LinearLayout>
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
index 3a691c108b..ed85a3cc05 100644
--- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
+++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
@@ -8,6 +8,7 @@
<string name="activity_map_fragment">Map Fragment Activity</string>
<string name="activity_press_for_marker">Press For Marker Activity</string>
<string name="activity_info_window">InfoWindow Activity</string>
+ <string name="activity_visible_coordinate_bounds">Visible Coordinate Bounds</string>
<string name="navdrawer_menu_title_mainactivity_controls">Main Activity Controls</string>
<string name="navdrawer_menu_title_mainactivity_styles">Main Activity Styles</string>
@@ -24,6 +25,7 @@
<string name="action_press_for_marker">Press For Marker</string>
<string name="action_info_window">InfoWindow</string>
<string name="action_visible_bounds">Set Visible Bounds</string>
+ <string name="action_visible_bounds_explanation">Center map around 2 markers</string>
<string name="label_fps">FPS:</string>