#894 - Placing InfoWindow directly on top of Marker sprite
This commit is contained in:
committed by
Justin R. Miller
parent
e52aa940de
commit
f3962b278f
@@ -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);
|
||||
|
||||
@@ -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
|
||||
//
|
||||
|
||||
|
||||
Reference in New Issue
Block a user