#894 - Placement of InfoWindow to marker location base

This commit is contained in:
Brad Leege
2015-09-02 14:50:47 -05:00
committed by Justin R. Miller
parent 10bbfe0164
commit 43107687ae
2 changed files with 10 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxgl.annotations;
import android.content.Context;
import android.view.Gravity;
import android.graphics.PointF;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -82,8 +82,14 @@ public class InfoWindow {
*/
public InfoWindow open(Marker object, LatLng position, int offsetX, int offsetY) {
onOpen(object);
MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT,
MapView.LayoutParams.WRAP_CONTENT, Gravity.CENTER|Gravity.BOTTOM);
MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT);
PointF coords = mMapView.toScreenLocation(position);
// 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;
close(); //if it was already opened
mMapView.addView(mView, lp);
mIsVisible = true;

View File

@@ -1,6 +1,5 @@
package com.mapbox.mapboxgl.views;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -1476,7 +1475,7 @@ public class MapView extends FrameLayout implements LocationListener {
// Called for events that don't fit the other handlers
// such as mouse scroll events, mouse moves, joystick, trackpad
@Override @TargetApi(12)
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
// Mouse events
//if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { // this is not available before API 18