#894 - Placing InfoWindow directly on top of Marker sprite

This commit is contained in:
Brad Leege
2015-09-03 16:25:54 -05:00
committed by Justin R. Miller
parent e52aa940de
commit f3962b278f
2 changed files with 13 additions and 3 deletions

View File

@@ -86,12 +86,14 @@ public class InfoWindow {
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
PointF coords = mMapView.toScreenLocation(position);
// double y = mMapView.getTopOffsetPixelsForAnnotationSymbol(object.sprite);
double y = mMapView.getTopOffsetPixelsForAnnotationSymbol(object.sprite);
y = y * mMapView.getScreenDensity();
// Flip y coordinate as Android view origin is upper left corner
coords.y = mMapView.getHeight() - coords.y;
lp.leftMargin = (int) coords.x - (mView.getMeasuredWidth() / 2);
lp.topMargin = (int) coords.y - (mView.getMeasuredHeight());
// Add y because it's a negative value
lp.topMargin = (int) coords.y - mView.getMeasuredHeight() + (int) y;
close(); //if it was already opened
mMapView.addView(mView, lp);

View File

@@ -732,7 +732,15 @@ public class MapView extends FrameLayout implements LocationListener {
return mNativeMapView.getTopOffsetPixelsForAnnotationSymbol(symbolName);
}
//
/**
* Common Screen Density
* @return Screen Density
*/
public float getScreenDensity() {
return mScreenDensity;
}
//
// Lifecycle events
//