summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-01-24 15:51:22 +0100
committerTobrun <tobrun.van.nuland@gmail.com>2018-01-24 16:04:38 +0100
commitee6b7fac7b0778272a6541ff079b0b98992fc259 (patch)
tree3f658ac39438ecf5f21f63d880ab253fc62e2552
parentfb5b8d34f20b696319cfc16838243265143ba972 (diff)
downloadqtlocation-mapboxgl-upstream/tvn-marker-snapshot-example-fix.tar.gz
[android] - correct marker location when using Snapshot#pixelForLatLngupstream/tvn-marker-snapshot-example-fix
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
index b690f18b6a..11d1df008a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
@@ -9,12 +9,14 @@ import android.support.v7.app.AppCompatActivity;
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;
/**
@@ -72,9 +74,10 @@ public class MapSnapshotterMarkerActivity extends AppCompatActivity implements M
// Dom toren
PointF markerLocation = snapshot.pixelForLatLng(new LatLng(52.090649433011315, 5.121310651302338));
canvas.drawBitmap(marker,
- markerLocation.x,
- /* Subtract height (in dp) so the bottom of the marker aligns correctly */
- markerLocation.y - (marker.getHeight() / getResources().getDisplayMetrics().density),
+ /* Subtract half of the width so we center the bitmap correctly */
+ markerLocation.x - marker.getWidth() / 2,
+ /* Subtract half of the height so we align the bitmap bottom correctly */
+ markerLocation.y - marker.getHeight() / 2,
null
);
return snapshot.getBitmap();