[android] - expose stylejsoon confiugration on MapboxMapOptions and MapView attributes

This commit is contained in:
Tobrun
2018-08-17 22:23:32 +02:00
committed by Tobrun
parent 5ce64b786c
commit 7ce6af3f55
7 changed files with 82 additions and 38 deletions

View File

@@ -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 {
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()
);
try {
map.setStyleJson(ResourceUtils.readRawResource(getApplicationContext(), R.raw.no_bg_style));
} catch (IOException exception) {
Timber.e(exception);
}
});
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();
}
}

View File

@@ -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>