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

Commit

Permalink
Added sample InfoWindowConcurrentActivity to illustrate the behavio…
Browse files Browse the repository at this point in the history
…r of multiple InfoWindows visible at a time (#3115).
  • Loading branch information
zugaldia committed Nov 30, 2015
1 parent 48504ba commit c66a69e
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 13 deletions.
19 changes: 6 additions & 13 deletions android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:label="@string/app_name">
Expand All @@ -23,47 +22,41 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".VisibleCoordinateBoundsActivity"
android:label="@string/activity_visible_coordinate_bounds" />

<activity
android:name=".InfoWindowAdapterActivity"
android:label="@string/activity_infowindow_adapter" />

<activity
android:name=".InfoWindowActivity"
android:label="@string/activity_info_window" />

<activity
android:name=".InfoWindowConcurrentActivity"
android:label="@string/activity_info_window_concurrent" />
<activity
android:name=".BulkMarkerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/action_add_bulk_markers" />

<activity
android:name=".MapFragmentActivity"
android:label="@string/activity_map_fragment" />

<activity
android:name=".PressForMarkerActivity"
android:label="@string/activity_press_for_marker" />

<activity android:name=".ManualZoomActivity"
android:label="@string/action_manual_zoom"/>

<activity
android:name=".ManualZoomActivity"
android:label="@string/action_manual_zoom" />
<activity
android:name=".MyLocationTrackingModeActivity"
android:label="@string/activity_user_tracking_mode" />

<activity
android:name=".PolylineActivity"
android:label="@string/activity_polyline" />

<meta-data
android:name="io.fabric.ApiKey"
android:value="9724157045ff7d083492c6d9ae03e60e8609d461" />

<meta-data
android:name="com.mapbox.AccessToken"
android:value="" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.mapbox.mapboxsdk.testapp;

import android.os.Bundle;
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.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;

public class InfoWindowConcurrentActivity extends AppCompatActivity {

private MapView mMapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infowindow_concurrent);

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.onCreate(savedInstanceState);

// Enable to let concurrent multiple infowindows to be shown.
mMapView.setAllowConcurrentMultipleOpenInfoWindows(true);

mMapView.addMarker(new MarkerOptions()
.title("Intersection")
.snippet("H St NW with 15th St NW")
.position(new LatLng(38.9002073, -77.03364419)));

mMapView.addMarker(new MarkerOptions()
.title("White House")
.snippet("The official residence and principal workplace of the President of the United States, located at 1600 Pennsylvania Avenue NW in Washington, D.C. It has been the residence of every U.S. president since John Adams in 1800.")
.position(new LatLng(38.897705003219784, -77.03655168667463)));

mMapView.addMarker(new MarkerOptions().title("Intersection")
.snippet("E St NW with 17th St NW")
.position(new LatLng(38.8954236, -77.0394623)));
}

@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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
startActivity(new Intent(getApplicationContext(), InfoWindowActivity.class));
return true;

case R.id.action_info_window_concurrent:
startActivity(new Intent(getApplicationContext(), InfoWindowConcurrentActivity.class));
return true;

case R.id.action_visible_bounds:
startActivity(new Intent(getApplicationContext(), VisibleCoordinateBoundsActivity.class));
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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="?attr/actionBarSize"
android:background="@color/primary"
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"
app:style_url="@string/style_mapbox_streets"
app:center_latitude="38.897705003219784"
app:center_longitude="-77.03655168667463"
app:zoom_level="15" />

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
android:icon="@drawable/ic_flip_to_front_24dp"
android:title="@string/action_info_window" />

<item
android:id="@+id/action_info_window_concurrent"
android:checkable="false"
android:icon="@drawable/ic_flip_to_front_24dp"
android:title="@string/action_info_window_concurrent" />

<item
android:id="@+id/action_info_window_adapter"
android:checkable="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<string name="activity_marker_in_bulk">Add Bulk Markers Activity</string>
<string name="activity_manual_zoom">Manual Zoom Activity</string>
<string name="activity_info_window">InfoWindow Activity</string>
<string name="activity_info_window_concurrent">InfoWindow Activity (Concurrent)</string>
<string name="activity_visible_coordinate_bounds">Visible Coordinate Bounds</string>
<string name="activity_user_tracking_mode">User tracking mode</string>
<string name="activity_polyline">Polyline Activity</string>
Expand All @@ -27,6 +28,7 @@
<string name="action_press_for_marker">Press For Marker</string>
<string name="action_manual_zoom">Manual Zoom</string>
<string name="action_info_window">InfoWindow</string>
<string name="action_info_window_concurrent">InfoWindow (Concurrent)</string>
<string name="action_add_bulk_markers">Add Markers in bulk</string>
<string name="action_visible_bounds">Set Visible Bounds</string>
<string name="action_visible_bounds_explanation">Center map around 2 markers</string>
Expand Down

0 comments on commit c66a69e

Please sign in to comment.