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

Correct marker location when using Snapshot#pixelForLatLng #11029

Merged
merged 1 commit into from
Jan 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
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;

/**
Expand Down Expand Up @@ -72,9 +74,10 @@ private Bitmap addMarker(MapSnapshot snapshot) {
// 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();
Expand Down