Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinguish the tapped marker from other markers; #1722

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ public boolean isFlat() {
return mFlat;
}

public void setFocused(boolean mFocused) {
if (mIcon == null) return;
if (mFocused) {
mIcon.setState(new int[]{android.R.attr.state_focused});
} else {
mIcon.setState(new int[]{android.R.attr.state_single});
}
}

/**
* Removes this Marker from the MapView.
* Note that this method will operate only if the Marker is in the MapView overlays
Expand Down Expand Up @@ -396,17 +405,24 @@ public boolean hitTest(final MotionEvent event, final MapView mapView) {
return mIcon != null && mDisplayed && mOrientedMarkerRect.contains((int) event.getX(), (int) event.getY()); // "!=null": fix for #1078
}

@Override
public boolean onSingleTapUp(MotionEvent e, MapView mapView) {
setFocused(false);
return super.onSingleTapUp(e, mapView);
}

@Override
public boolean onSingleTapConfirmed(final MotionEvent event, final MapView mapView) {
boolean touched = hitTest(event, mapView);
setFocused(touched);
if (touched) {
if (mOnMarkerClickListener == null) {
return onMarkerClickDefault(this, mapView);
} else {
return mOnMarkerClickListener.onMarkerClick(this, mapView);
}
} else
return touched;
return false;
}

public void moveToEventPosition(final MotionEvent event, final MapView mapView) {
Expand Down