This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] demo app - map snapshotter activity
- Loading branch information
1 parent
ca52474
commit a12ed5a
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.mapbox.mapboxsdk.testapp.activity.snapshot; | ||
|
||
import android.graphics.Bitmap; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.ImageView; | ||
|
||
import com.mapbox.mapboxsdk.constants.Style; | ||
import com.mapbox.mapboxsdk.maps.MapboxMap; | ||
import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter; | ||
import com.mapbox.mapboxsdk.testapp.R; | ||
|
||
import timber.log.Timber; | ||
|
||
/** | ||
* Test activity showing how to use a the {@link com.mapbox.mapboxsdk.snapshotter.MapSnapshotter} | ||
*/ | ||
public class MapSnapshotterActivity extends AppCompatActivity { | ||
|
||
private ImageView imageView; | ||
private MapSnapshotter snapshotter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_map_snapshotter); | ||
imageView = (ImageView) findViewById(R.id.map_snapshot_image); | ||
|
||
snapshotter = new MapSnapshotter(this, new MapSnapshotter.Options(512, 512 , Style.TRAFFIC_DAY)); | ||
snapshotter.start(new MapboxMap.SnapshotReadyCallback() { | ||
@Override | ||
public void onSnapshotReady(Bitmap snapshot) { | ||
Timber.i("Got the snapshot"); | ||
imageView.setImageBitmap(snapshot); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
//snapshotter.stop(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_snapshotter.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:id="@+id/map_snapshot_image" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:contentDescription="@null" | ||
android:src="@drawable/mapbox_logo_icon"/> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters