Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #3115 reposition info windows that have been repositioned w…
Browse files Browse the repository at this point in the history
…hile panning the map
  • Loading branch information
tobrun committed Nov 25, 2015
1 parent 936d1c0 commit 0cf326d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -152,6 +153,8 @@ InfoWindow open(Marker boundMarker, LatLng position, int offsetX, int offsetY) {
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;
Expand Down Expand Up @@ -235,7 +238,7 @@ public void update() {
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);
}
}
Expand Down

0 comments on commit 0cf326d

Please sign in to comment.