Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] demo app - map snapshotter activity
Browse files Browse the repository at this point in the history
  • Loading branch information
ivovandongen committed Aug 10, 2017
1 parent ca52474 commit a12ed5a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity"/>
</activity>
<activity android:name=".activity.snapshot.MapSnapshotterActivity"
android:description="@string/description_map_snapshotter"
android:label="@string/activity_map_snapshotter">
<meta-data
android:name="@string/category"
android:value="@string/category_imagegenerator"/>
</activity>
<activity
android:name=".activity.maplayout.DoubleMapActivity"
android:description="@string/description_doublemap"
Expand Down
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();
}

}
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>
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<string name="activity_building_fill_extrusion_layer">Building layer</string>
<string name="activity_animated_image_source">Animated Image Source</string>
<string name="activity_bottom_sheet">Bottom sheet</string>
<string name="activity_map_snapshotter">Map Snapshotter</string>

<!--Description-->
<string name="description_user_location_tracking">Tracks the location of the user</string>
Expand Down Expand Up @@ -125,6 +126,7 @@
<string name="description_building_fill_extrusion_layer">Shows how to show 3D extruded buildings</string>
<string name="description_animated_image_source">Shows how to animate georeferenced images</string>
<string name="description_bottom_sheet">Show 2 MapView on screen with a bottom sheet</string>
<string name="description_map_snapshotter">Show a static bitmap taken with the MapSnapshotter</string>

<!--Categories-->
<string name="category">category</string>
Expand Down

0 comments on commit a12ed5a

Please sign in to comment.