diff options
author | Tobrun <tobrun@mapbox.com> | 2016-05-09 10:03:45 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2016-05-20 12:00:02 +0200 |
commit | 69ae499a88a37b7ad21e53de8929930f8c22e0e3 (patch) | |
tree | ff2b9d5ba16af63f1b586588cf91ff32ab928ef9 /platform/android/MapboxGLAndroidSDKTestApp | |
parent | d8dfc921b4d9c9f15bdd33c45ef7d2d77e04ba1b (diff) | |
download | qtlocation-mapboxgl-69ae499a88a37b7ad21e53de8929930f8c22e0e3.tar.gz |
[android] #3276 - View Marker click listener integration
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/ViewMarkerActivity.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/ViewMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/ViewMarkerActivity.java index 7467d2993d..de4aa81a60 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/ViewMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/ViewMarkerActivity.java @@ -7,14 +7,18 @@ import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -50,7 +54,9 @@ public class ViewMarkerActivity extends AppCompatActivity implements OnMapReadyC } @Override - public void onMapReady(MapboxMap mapboxMap) { + public void onMapReady(final MapboxMap mapboxMap) { + + // Add country markers List<BaseMarkerOptions> countries = new ArrayList<>(); countries.add(new CountryMarkerOptions().title("China").abbrevName("ch").flagRes(R.drawable.ic_china).position(new LatLng(31.230416, 121.473701))); countries.add(new CountryMarkerOptions().title("United States").abbrevName("us").flagRes(R.drawable.ic_us).position(new LatLng(38.907192, -77.036871))); @@ -58,9 +64,17 @@ public class ViewMarkerActivity extends AppCompatActivity implements OnMapReadyC countries.add(new CountryMarkerOptions().title("Germany").abbrevName("de").flagRes(R.drawable.ic_germany).position(new LatLng(52.520007, 13.404954))); mapboxMap.addMarkers(countries); + // Add view marker adapter mapboxMap.setMarkerViewAdapter(new CountryAdapter(this)); + mapboxMap.setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() { + @Override + public void onMarkerClick(@NonNull Marker marker, @NonNull View view) { + Log.d(MapboxConstants.TAG, "Country clicked " + ((CountryMarker) marker).getAbbrevName()); + } + }); } + private static class CountryAdapter implements MapboxMap.MarkerViewAdapter<CountryMarker> { private LayoutInflater inflater; |