diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2015-11-25 11:24:30 +0000 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2015-11-25 11:24:30 +0000 |
commit | 0cf326d668dc2318ca50f753c956b4532e25a288 (patch) | |
tree | 11cba95a97ce8a9b67a1d28ce61549ea9795befd /android | |
parent | 936d1c01b28b1edd3961a2fb15a99562fe7af029 (diff) | |
download | qtlocation-mapboxgl-0cf326d668dc2318ca50f753c956b4532e25a288.tar.gz |
[android] #3115 reposition info windows that have been repositioned while panning the map
Diffstat (limited to 'android')
-rw-r--r-- | android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java index c9ca2acb52..220b37ed1f 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java @@ -23,6 +23,7 @@ public class InfoWindow { private WeakReference<Marker> mBoundMarker; private WeakReference<MapView> mMapView; private float mMarkerHeightOffset; + private float mViewWidthOffset; private boolean mIsVisible; protected View mView; @@ -152,6 +153,8 @@ public class InfoWindow { mView.setX(x); mView.setY(y); + mViewWidthOffset = x - (coords.x - (mView.getMeasuredWidth() / 2) + offsetX); + close(); //if it was already opened mMapView.get().addView(mView, lp); mIsVisible = true; @@ -235,7 +238,7 @@ public class InfoWindow { Marker marker = mBoundMarker.get(); if (mapView != null && marker != null) { PointF pointF = mapView.toScreenLocation(marker.getPosition()); - mView.setX(pointF.x - mView.getWidth() / 2); + mView.setX((pointF.x - (mView.getWidth() / 2)) + mViewWidthOffset); mView.setY(pointF.y - mView.getHeight() + mMarkerHeightOffset); } } |