Repository navigation
Hit test Marker and MarkerViews - #9424
Conversation
b2298c8 to
3847550
Compare
|
Code has been re-factored (initial implementation was made for backporting that behaviour). |
3847550 to
29cda9c
Compare
| private boolean isClickHandledForMarker(long markerId) { | ||
| boolean handledDefaultClick; | ||
| Marker marker = (Marker) getAnnotation(markerId); | ||
| if (marker instanceof MarkerView) { |
There was a problem hiding this comment.
If we continue evolving AnnotationManager keeping both Markers and MarkerViews, we should think about implementing an Strategy pattern around Marker and MarkerView.
There was a problem hiding this comment.
good idea, would love to get in #6912 first as this will changes the whole setup around annotations (this makes 50% of our current java code around annotations obsolete) and would like to avoid doing twice the work.
| this.projection = projection; | ||
| } | ||
|
|
||
| public long execute(MarkerHit markerHit) { |
There was a problem hiding this comment.
We should strive to keeppublic methods as clean as possible so they read like pseudocode (no conditionals, fors, etc.). What about extracting some private methods to make it simpler?
There was a problem hiding this comment.
Replaced with
public long execute(MarkerHit markerHit) {
resolveForMarkers(markerHit);
return closestMarkerId;
}
private void resolveForMarkers(MarkerHit markerHit){
for (Marker marker : markerHit.markers) {
if (marker instanceof MarkerView) {
resolveForMarkerView(markerHit, (MarkerView) marker);
} else {
resolveForMarker(markerHit, marker);
}
}
}
| bitmap = marker.getIcon().getBitmap(); | ||
| hitRectMarker.set(0, 0, bitmap.getWidth(), bitmap.getHeight()); | ||
| hitRectMarker.offsetTo( | ||
| markerLocation.x - bitmap.getWidth() / 2, |
There was a problem hiding this comment.
What about extracting these expressions into explaining variables? E.g. averageXXX
29cda9c to
aaa5518
Compare
* [android] - hit test Marker and MarkerViews * fixup
* [android] - hit test Marker and MarkerViews * fixup
WIP, Closes #8159.
This PR adds hit testing to Markers and MarkerViews, we first query the map for nearby markers and on that result we perform rectangular hit testing. If we hit multiple annotation (eg. overlapping), we will make an intersection between the touch target and the bounds of the annotation to determine which annotation should be selected. This PR requires some re factoring before merging.