diff options
2 files changed, 10 insertions, 5 deletions
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java index 924012db52..f646386f45 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/annotations/InfoWindow.java @@ -1,7 +1,7 @@ package com.mapbox.mapboxgl.annotations; import android.content.Context; -import android.view.Gravity; +import android.graphics.PointF; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -82,8 +82,14 @@ public class InfoWindow { */ public InfoWindow open(Marker object, LatLng position, int offsetX, int offsetY) { onOpen(object); - MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, - MapView.LayoutParams.WRAP_CONTENT, Gravity.CENTER|Gravity.BOTTOM); + MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT); + PointF coords = mMapView.toScreenLocation(position); + + // Flip y coordinate as Android view origin is upper left corner + coords.y = mMapView.getHeight() - coords.y; + lp.leftMargin = (int) coords.x; + lp.topMargin = (int) coords.y; + close(); //if it was already opened mMapView.addView(mView, lp); mIsVisible = true; diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 829e3fe2d7..98abda1d09 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -1,6 +1,5 @@ package com.mapbox.mapboxgl.views; -import android.annotation.TargetApi; import android.app.ActivityManager; import android.content.BroadcastReceiver; import android.content.Context; @@ -1476,7 +1475,7 @@ public class MapView extends FrameLayout implements LocationListener { // Called for events that don't fit the other handlers // such as mouse scroll events, mouse moves, joystick, trackpad - @Override @TargetApi(12) + @Override public boolean onGenericMotionEvent(MotionEvent event) { // Mouse events //if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { // this is not available before API 18 |