diff options
author | Brad Leege <bleege@gmail.com> | 2015-09-02 14:50:47 -0500 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-09-07 12:03:33 -0700 |
commit | 43107687ae37151bb32a1e9fc50f4dacca91d914 (patch) | |
tree | de9c07cc37dc3518516c8ead33efa1302417900d /android/java/MapboxGLAndroidSDK/src/main | |
parent | 10bbfe01641fb0465549e128c8a99502221e5db7 (diff) | |
download | qtlocation-mapboxgl-43107687ae37151bb32a1e9fc50f4dacca91d914.tar.gz |
#894 - Placement of InfoWindow to marker location base
Diffstat (limited to 'android/java/MapboxGLAndroidSDK/src/main')
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 |