#894 - Flipping the Y value to make screen touch event locations line up with marker. Updating marker selection and deselection logic to allow for proper selection and reselection.

This commit is contained in:
Brad Leege
2015-09-04 18:52:08 -05:00
committed by Justin R. Miller
parent 77951eea93
commit 8f98024f37

View File

@@ -8,7 +8,10 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PointF;
import android.hardware.GeomagneticField;
import android.hardware.Sensor;
@@ -1033,10 +1036,18 @@ public class MapView extends FrameLayout implements LocationListener {
mNativeMapView.cancelTransitions();
// Open / Close InfoWindow
PointF tapPoint = new PointF(e.getX(), e.getY());
float x = e.getX();
float y = e.getY();
// flip y direction vertically to match core GL
y = getHeight() - y;
PointF tapPoint = new PointF(x, y);
LatLng tapLatLng = fromScreenLocation(tapPoint);
float toleranceWidth = 60 * mScreenDensity;
float toleranceHeight = 80 * mScreenDensity;
float toleranceHeight = 200 * mScreenDensity;
PointF tr = new PointF(tapPoint.x + toleranceWidth / 2, tapPoint.y + 2 * toleranceHeight / 3);
PointF bl = new PointF(tapPoint.x - toleranceWidth / 2, tapPoint.y - 1 * toleranceHeight / 3);
@@ -1046,6 +1057,8 @@ public class MapView extends FrameLayout implements LocationListener {
BoundingBox bbox = new BoundingBox(ne, sw);
addPolyline(new PolylineOptions().add(sw, ne).color(Color.RED).width(5));
List<Annotation> nearbyAnnotations = getAnnotationsInBounds(bbox);
long newSelectedAnnotationID = -1;
@@ -1096,11 +1109,13 @@ public class MapView extends FrameLayout implements LocationListener {
if (newSelectedAnnotationID >= 0) {
for (Annotation annotation : mAnnotations) {
if (annotation.getId() == newSelectedAnnotationID) {
if (annotation.getId() == mSelectedAnnotation.getId()) {
selectAnnotation(annotation);
if (annotation instanceof Marker) {
if (annotation.getId() == newSelectedAnnotationID) {
if (mSelectedAnnotation == null || annotation.getId() != mSelectedAnnotation.getId()) {
selectAnnotation(annotation);
}
break;
}
break;
}
}
@@ -1989,6 +2004,7 @@ public class MapView extends FrameLayout implements LocationListener {
Marker marker = (Marker) mSelectedAnnotation;
if (marker.isInfoWindowShown()) {
marker.hideInfoWindow();
mSelectedAnnotation = null;
}
}
}