diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-08-17 22:23:32 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-08-21 17:27:09 +0200 |
commit | 7ce6af3f55d94e5e271aeafff44a11508b79dead (patch) | |
tree | a3955c36afcca78405aff7da7c10af0b005546bd /platform/android/MapboxGLAndroidSDKTestApp/src/main | |
parent | 5ce64b786cfd2fbfdc28ccfbcf9c1a5216346281 (diff) | |
download | qtlocation-mapboxgl-7ce6af3f55d94e5e271aeafff44a11508b79dead.tar.gz |
[android] - expose stylejsoon confiugration on MapboxMapOptions and MapView attributes
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main')
2 files changed, 23 insertions, 24 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewTransparentBackgroundActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewTransparentBackgroundActivity.java index 15da018b0e..3a62e39173 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewTransparentBackgroundActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewTransparentBackgroundActivity.java @@ -2,10 +2,14 @@ package com.mapbox.mapboxsdk.testapp.activity.textureview; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.view.ViewGroup; import android.widget.ImageView; +import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils; @@ -30,23 +34,30 @@ public class TextureViewTransparentBackgroundActivity extends AppCompatActivity } private void setupBackground() { - ImageView imageView = (ImageView) findViewById(R.id.imageView); + ImageView imageView = findViewById(R.id.imageView); imageView.setImageResource(R.drawable.water); imageView.setScaleType(ImageView.ScaleType.FIT_XY); } private void setupMapView(Bundle savedInstanceState) { - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(map -> { - mapboxMap = map; - - try { - map.setStyleJson(ResourceUtils.readRawResource(getApplicationContext(), R.raw.no_bg_style)); - } catch (IOException exception) { - Timber.e(exception); - } - }); + try { + MapboxMapOptions mapboxMapOptions = new MapboxMapOptions(); + mapboxMapOptions.styleJson(ResourceUtils.readRawResource(this, R.raw.no_bg_style)); + mapboxMapOptions.translucentTextureSurface(true); + mapboxMapOptions.textureMode(true); + mapboxMapOptions.camera(new CameraPosition.Builder() + .zoom(2) + .target(new LatLng(48.507879, 8.363795)) + .build() + ); + + mapView = new MapView(this, mapboxMapOptions); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(map -> mapboxMap = map); + ((ViewGroup) findViewById(R.id.coordinator_layout)).addView(mapView); + } catch (IOException exception) { + Timber.e(exception); + } } @Override @@ -90,5 +101,4 @@ public class TextureViewTransparentBackgroundActivity extends AppCompatActivity super.onLowMemory(); mapView.onLowMemory(); } - }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_textureview_transparent.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_textureview_transparent.xml index 1d99e61d74..096d44e223 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_textureview_transparent.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_textureview_transparent.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent" @@ -13,15 +12,5 @@ android:layout_height="match_parent" android:contentDescription="@null"/> - <com.mapbox.mapboxsdk.maps.MapView - android:id="@+id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - app:mapbox_cameraTargetLat="48.507879" - app:mapbox_cameraTargetLng="8.363795" - app:mapbox_cameraZoom="2" - app:mapbox_renderTextureMode="true" - app:mapbox_renderTextureTranslucentSurface="true"/> - </android.support.design.widget.CoordinatorLayout> |