[android] - add LatLng for pixel conversion feature to MapSnapshotter
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.snapshot;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.snapshotter.MapSnapshot;
|
||||
import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
@@ -26,6 +26,7 @@ import timber.log.Timber;
|
||||
public class MapSnapshotterMarkerActivity extends AppCompatActivity implements MapSnapshotter.SnapshotReadyCallback {
|
||||
|
||||
private MapSnapshotter mapSnapshotter;
|
||||
private MapSnapshot mapSnapshot;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -60,12 +61,21 @@ public class MapSnapshotterMarkerActivity extends AppCompatActivity implements M
|
||||
mapSnapshotter.cancel();
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onSnapshotReady(MapSnapshot snapshot) {
|
||||
Timber.i("Snapshot ready");
|
||||
ImageView imageView = (ImageView) findViewById(R.id.snapshot_image);
|
||||
Bitmap image = addMarker(snapshot);
|
||||
imageView.setImageBitmap(image);
|
||||
imageView.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
LatLng latLng = snapshot.latLngForPixel(new PointF(event.getX(), event.getY()));
|
||||
Timber.e("Clicked LatLng is %s", latLng);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private Bitmap addMarker(MapSnapshot snapshot) {
|
||||
|
||||
Reference in New Issue
Block a user