summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-01-11 11:32:00 +0100
committerTobrun <tobrun@mapbox.com>2016-01-29 13:15:58 +0100
commit8ed1dc9f7412d61a66bae576346f2674e6ab3926 (patch)
treecdd6ee3b83dcdb3733a80cb46797318b6598dda7 /platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java
parent710398b780cc05e961a9c58c18176af46bbd34be (diff)
downloadqtlocation-mapboxgl-8ed1dc9f7412d61a66bae576346f2674e6ab3926.tar.gz
[android] #3145 - MapboxMap
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java77
1 files changed, 40 insertions, 37 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java
index 7ef71a9408..e34bff9eed 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java
@@ -7,12 +7,14 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.utils.ApiAccess;
-import com.mapbox.mapboxsdk.views.MapView;
+import com.mapbox.mapboxsdk.maps.MapView;
import java.text.DecimalFormat;
@@ -38,43 +40,44 @@ public class InfoWindowActivity extends AppCompatActivity {
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")
- .icon(IconFactory.getInstance(this).fromAsset("london-underground-24.png"))
- .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.")
- .icon(mMapView.getIconFactory().fromAsset("town-hall-24.png"))
- .position(new LatLng(38.897705003219784, -77.03655168667463)));
-
- mMapView.addMarker(new MarkerOptions().title("Intersection")
- .snippet("E St NW with 17th St NW")
- .icon(mMapView.getIconFactory().fromAsset("commercial-24.png"))
- .position(new LatLng(38.8954236, -77.0394623)));
-
- final DecimalFormat formatter = new DecimalFormat("#.#####");
- mMapView.setOnMapLongClickListener(new MapView.OnMapLongClickListener() {
+ mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
- public void onMapLongClick(@NonNull LatLng point) {
-
- // Remove previous added marker
- if (mCustomMarker != null) {
- mMapView.removeAnnotation(mCustomMarker);
- mCustomMarker = null;
- }
-
- // Add marker on long click location with default marker image
- mCustomMarker = mMapView.addMarker(new MarkerOptions()
- .title("Custom Marker")
- .snippet(formatter.format(point.getLatitude()) + ", " + formatter.format(point.getLongitude()))
- .position(point));
+ public void onMapReady(@NonNull final MapboxMap mapboxMap) {
+ mapboxMap.addMarker(new MarkerOptions()
+ .title("Intersection")
+ .snippet("H St NW with 15th St NW")
+ .icon(IconFactory.getInstance(InfoWindowActivity.this)
+ .fromAsset("london-underground-24.png"))
+ .position(new LatLng(38.9002073, -77.03364419)));
+
+ mapboxMap.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.")
+ .icon(IconFactory.getInstance(InfoWindowActivity.this).fromAsset("town-hall-24.png"))
+ .position(new LatLng(38.897705003219784, -77.03655168667463)));
+
+ mapboxMap.addMarker(new MarkerOptions().title("Intersection")
+ .snippet("E St NW with 17th St NW")
+ .icon(IconFactory.getInstance(InfoWindowActivity.this).fromAsset("commercial-24.png"))
+ .position(new LatLng(38.8954236, -77.0394623)));
+
+ final DecimalFormat formatter = new DecimalFormat("#.#####");
+ mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() {
+ @Override
+ public void onMapLongClick(@NonNull LatLng point) {
+ // Remove previous added marker
+ if (mCustomMarker != null) {
+ mapboxMap.removeAnnotation(mCustomMarker);
+ mCustomMarker = null;
+ }
+
+ // Add marker on long click location with default marker image
+ mCustomMarker = mapboxMap.addMarker(new MarkerOptions()
+ .title("Custom Marker")
+ .snippet(formatter.format(point.getLatitude()) + ", " + formatter.format(point.getLongitude()))
+ .position(point));
+ }
+ });
}
});
}