[android] #3115 reposition info windows that have been repositioned while panning the map

This commit is contained in:
Tobrun
2015-11-25 11:24:30 +00:00
parent 936d1c01b2
commit 0cf326d668

View File

@@ -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);
}
}