From ae2a0475efc120d68caa9c0e2c92d14b9617f80e Mon Sep 17 00:00:00 2001 From: langsmith Date: Mon, 22 Jul 2019 11:16:24 -0700 Subject: initial additions --- .../activity/maplayout/SimpleMapActivity.java | 115 ++++++++++++++++++++- .../src/main/res/drawable-hdpi/antony.png | Bin 0 -> 32703 bytes .../src/main/res/drawable-hdpi/carlos.png | Bin 0 -> 43120 bytes .../src/main/res/drawable-hdpi/luciana.png | Bin 0 -> 29874 bytes .../src/main/res/drawable-hdpi/maria.png | Bin 0 -> 30792 bytes .../src/main/res/drawable-mdpi/antony.png | Bin 0 -> 15370 bytes .../src/main/res/drawable-mdpi/carlos.png | Bin 0 -> 20627 bytes .../src/main/res/drawable-mdpi/luciana.png | Bin 0 -> 14432 bytes .../src/main/res/drawable-mdpi/maria.png | Bin 0 -> 14939 bytes .../src/main/res/drawable-xhdpi/antony.png | Bin 0 -> 55871 bytes .../src/main/res/drawable-xhdpi/carlos.png | Bin 0 -> 74129 bytes .../src/main/res/drawable-xhdpi/luciana.png | Bin 0 -> 50651 bytes .../src/main/res/drawable-xhdpi/maria.png | Bin 0 -> 52512 bytes .../src/main/res/drawable-xxhdpi/antony.png | Bin 0 -> 117053 bytes .../src/main/res/drawable-xxhdpi/carlos.png | Bin 0 -> 152538 bytes .../src/main/res/drawable-xxhdpi/luciana.png | Bin 0 -> 103730 bytes .../src/main/res/drawable-xxhdpi/maria.png | Bin 0 -> 108291 bytes .../src/main/res/drawable-xxxhdpi/antony.png | Bin 0 -> 194216 bytes .../src/main/res/drawable-xxxhdpi/carlos.png | Bin 0 -> 251039 bytes .../src/main/res/drawable-xxxhdpi/luciana.png | Bin 0 -> 169842 bytes .../src/main/res/drawable-xxxhdpi/maria.png | Bin 0 -> 177625 bytes 21 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/antony.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/carlos.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/luciana.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/maria.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/antony.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/carlos.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/luciana.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/maria.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/antony.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/carlos.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/luciana.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/maria.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/antony.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/carlos.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/luciana.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/maria.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/antony.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/carlos.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/luciana.png create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/maria.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java index 8406fe2332..4fb77c5a83 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java @@ -1,12 +1,31 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; + +import com.mapbox.geojson.Feature; +import com.mapbox.geojson.FeatureCollection; +import com.mapbox.geojson.Point; import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.Style; +import com.mapbox.mapboxsdk.style.layers.SymbolLayer; +import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.utils.NavUtils; +import com.mapbox.mapboxsdk.utils.BitmapUtils; + +import static com.mapbox.mapboxsdk.style.expressions.Expression.get; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset; /** * Test activity showcasing a simple MapView without any MapboxMap interaction. @@ -14,6 +33,16 @@ import com.mapbox.mapboxsdk.testapp.utils.NavUtils; public class SimpleMapActivity extends AppCompatActivity { private MapView mapView; + private static final String ICON_SOURCE_ID = "ICON_SOURCE_ID"; + private static final String ICON_LAYER_ID = "ICON_LAYER_ID"; + private static final String PROFILE_NAME = "PROFILE_NAME"; + private static final String CARLOS = "Carlos"; + private static final String ANTONY = "Antony"; + + private static final String MARIA = "Maria"; + private static final String LUCIANA = "Luciana"; + private MapboxMap mapboxMap; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -21,9 +50,89 @@ public class SimpleMapActivity extends AppCompatActivity { setContentView(R.layout.activity_map_simple); mapView = findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); - mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle( - new Style.Builder().fromUri(Style.MAPBOX_STREETS) - )); + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(@NonNull final MapboxMap mapboxMap) { + + // Add Features which represent the location of each profile photo SymbolLayer icon + Feature carlosFeature = Feature.fromGeometry(Point.fromLngLat(-7.9760742, + 41.2778064)); + carlosFeature.addStringProperty(PROFILE_NAME, CARLOS); + + Feature antonyFeature = Feature.fromGeometry(Point.fromLngLat(-8.0639648, + 37.5445773)); + antonyFeature.addStringProperty(PROFILE_NAME, ANTONY); + + Feature mariaFeature = Feature.fromGeometry(Point.fromLngLat(-9.1845703, + 38.9764924)); + mariaFeature.addStringProperty(PROFILE_NAME, MARIA); + + Feature lucianaFeature = Feature.fromGeometry(Point.fromLngLat(-7.5146484, + 40.2459915)); + lucianaFeature.addStringProperty(PROFILE_NAME, LUCIANA); + + // Use a URL to build and add a Style object to the map. Then add a source to the Style. + mapboxMap.setStyle( + new Style.Builder().fromUri(Style.LIGHT) + .withSource(new GeoJsonSource(ICON_SOURCE_ID, + FeatureCollection.fromFeatures(new Feature[] { + carlosFeature, + antonyFeature, + mariaFeature, + lucianaFeature}))), + new Style.OnStyleLoaded() { + @Override + public void onStyleLoaded(@NonNull Style style) { + SimpleMapActivity.this.mapboxMap = mapboxMap; + + // Add a SymbolLayer to the style. iconImage is set to a value that will + // be used later in the addOnStyleImageMissingListener below + style.addLayer(new SymbolLayer(ICON_LAYER_ID, ICON_SOURCE_ID).withProperties( + iconImage(get(PROFILE_NAME)), + iconIgnorePlacement(true), + iconAllowOverlap(true), + textField(get(PROFILE_NAME)), + textIgnorePlacement(true), + textAllowOverlap(true), + textOffset(new Float[] {0f, 2f}) + )); + } + }); + } + }); + + // Use the listener to match the id with the appropriate person. The correct profile photo is + // given to the map during "runtime". + mapView.addOnStyleImageMissingListener(new MapView.OnStyleImageMissingListener() { + @Override + public void onStyleImageMissing(@NonNull String id) { + switch (id) { + case CARLOS: + addImage(id, R.drawable.carlos); + break; + case ANTONY: + addImage(id, R.drawable.antony); + break; + case MARIA: + addImage(id, R.drawable.maria); + break; + case LUCIANA: + addImage(id, R.drawable.luciana); + break; + default: + addImage(id, R.drawable.carlos); + break; + } + } + }); + } + + private void addImage(String id, int drawableImage) { + Style style = mapboxMap.getStyle(); + if (style != null) { + style.addImageAsync(id, BitmapUtils.getBitmapFromDrawable( + getResources().getDrawable(drawableImage))); + } } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/antony.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/antony.png new file mode 100644 index 0000000000..cf41964acd Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/antony.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/carlos.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/carlos.png new file mode 100644 index 0000000000..8d17d90b0b Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/carlos.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/luciana.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/luciana.png new file mode 100644 index 0000000000..b21c9a5ec6 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/luciana.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/maria.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/maria.png new file mode 100644 index 0000000000..462a43ebbd Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/maria.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/antony.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/antony.png new file mode 100644 index 0000000000..4dc7a72586 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/antony.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/carlos.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/carlos.png new file mode 100644 index 0000000000..67d5a2a7a5 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/carlos.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/luciana.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/luciana.png new file mode 100644 index 0000000000..5b805d9fc3 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/luciana.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/maria.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/maria.png new file mode 100644 index 0000000000..3c03c30a31 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/maria.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/antony.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/antony.png new file mode 100644 index 0000000000..bbd931b520 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/antony.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/carlos.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/carlos.png new file mode 100644 index 0000000000..d8f73bec83 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/carlos.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/luciana.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/luciana.png new file mode 100644 index 0000000000..be42b2b5b3 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/luciana.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/maria.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/maria.png new file mode 100644 index 0000000000..6b2967a579 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/maria.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/antony.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/antony.png new file mode 100644 index 0000000000..e2e517df38 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/antony.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/carlos.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/carlos.png new file mode 100644 index 0000000000..32e0541f47 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/carlos.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/luciana.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/luciana.png new file mode 100644 index 0000000000..321eb89b91 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/luciana.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/maria.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/maria.png new file mode 100644 index 0000000000..780cd0e2c5 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/maria.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/antony.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/antony.png new file mode 100644 index 0000000000..85d1e4c155 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/antony.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/carlos.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/carlos.png new file mode 100644 index 0000000000..091d4590cc Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/carlos.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/luciana.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/luciana.png new file mode 100644 index 0000000000..861865e0d5 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/luciana.png differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/maria.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/maria.png new file mode 100644 index 0000000000..69cd52e2e1 Binary files /dev/null and b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/maria.png differ -- cgit v1.2.1