Skip to content

Commit

Permalink
mapbox#894 - Initial port of iOS method for aligning infowindows over…
Browse files Browse the repository at this point in the history
… markers
  • Loading branch information
bleege authored and incanus committed Sep 7, 2015
1 parent cd6fd82 commit 68a250d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ public InfoWindow open(Marker object, LatLng position, int offsetX, int offsetY)
MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT);
PointF coords = mMapView.toScreenLocation(position);

double y = mMapView.getTopOffsetPixelsForAnnotationSymbol(object.sprite);

// 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;
lp.leftMargin = (int) coords.x - 1;
lp.topMargin = (int) coords.y + (int) y;

close(); //if it was already opened
mMapView.addView(mView, lp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,11 @@ public PointF toScreenLocation(LatLng location) {
return new PointF(point.x * mScreenDensity, point.y * mScreenDensity);
}

//
public double getTopOffsetPixelsForAnnotationSymbol(@NonNull String symbolName) {
return mNativeMapView.getTopOffsetPixelsForAnnotationSymbol(symbolName);
}

//
// Lifecycle events
//

Expand Down

0 comments on commit 68a250d

Please sign in to comment.