You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
We have seen a couple of reports related to clicks on Marker and MarkerViews (#8158 / #8118). The root cause of these issues is the way we handle touch interaction with these components.
Both implementations of Markers rely on QueryPointAnnotations. This uses a rectangle to query the map for annotations. We currently try optimising the size of the rectangle with the average size of icons added to the map. This approach isn't ideal as sometimes the click isn't fired while you would expect it to.
For MarkerViews we used to rely on click events on the Views itself but that resulted in issues as #5388. I want to look into bringing back view click handling as this will bring the best ux and allows for defining Android sdk selectors.
MarkerView clicks are now handled back on the View object since #8272. Relying on the platform implementation will provide the UX users are expecting. What remains for this ticket to close is optimizing the touch target for gl-based markers.
Same problem here. When clicking a markerview, first click infowindow is showed. Only at the second click, onMarkerClick is triggered. You need to click a markerview 2 times to trigger the onMarkerClick, and infowindow always appear.
Any news on this? I think having bottom centered annotations in a map AND allow the user to select them is not a too uncommon use-case. At least a workaround would be nice.
@MikeKasperlik@nijs9 this has been solved in #8991 afaik the fix will be released next monday, but if you want you can already use the SNAPSHOT version:
By the way, is this still related on marker clicks very large clickable area? This is really urgent in my case. I have my marker asset (which is a pointed marker) 2x height so it centers on its target. Unfortunately, this also enlarges its touch area such that tapping below the marker selects the marker itself, even though there is no marker there.
This really gets worse if you have a lot of markers in the screen. Selection jumps from marker to another. It is in fact annoying.
Due to high request on this ticket, we are handling this as a high priority. Optimizing click events for all different size markers is a hard problem. To unblock you, I'm adding an example workaround. Though it needs to be fine tuned for your specific use-case + might need some additional InfoWindow management:
mapboxMap.setOnMarkerClickListener(newMapboxMap.OnMarkerClickListener() {
@OverridepublicbooleanonMarkerClick(@NonNullMarkermarker) {
// no opreturntrue; // returning true here = handling click event ourselves
}
});
mapView.setOnTouchListener(newView.OnTouchListener() {
privateintCLICK_ACTION_THRESHHOLD = 200;
privatefloatstartX;
privatefloatstartY;
@OverridepublicbooleanonTouch(Viewv, MotionEventevent) {
switch (event.getAction()) {
caseMotionEvent.ACTION_DOWN:
startX = event.getX();
startY = event.getY();
break;
caseMotionEvent.ACTION_UP:
floatendX = event.getX();
floatendY = event.getY();
if (isAClick(startX, endX, startY, endY)) {
// the following invocation can also take in a rectangle instead of a PointList<Feature> features = mapboxMap.queryRenderedFeatures(newPointF(endX, endY), "com.mapbox.annotations.points");
Timber.e("features size: %s", features.size());
if(features.size()>0) {
Featuref = features.get(0);
Timber.e("features data: %s / %s / %s", f.getId(), f.getGeometry(),f.getType());
List<Marker>markers = mapboxMap.getMarkers();
for (Markermarker : markers) {
if(f.getId().equals(String.valueOf(marker.getId()))){
mapboxMap.selectMarker(marker);
}
}
}
}
returntrue;
}
returnfalse;
}
privatebooleanisAClick(floatstartX, floatendX, floatstartY, floatendY) {
floatdifferenceX = Math.abs(startX - endX);
floatdifferenceY = Math.abs(startY - endY);
if (differenceX > CLICK_ACTION_THRESHHOLD || differenceY > CLICK_ACTION_THRESHHOLD) {
returnfalse;
}
returntrue;
}
});
Hi I'm using MarkerViews, i have a layer of hexagons (like a bee hive) and markers in every hexagon, they are next to each others, but the click works just around the center of the view I've tried using both fixed and unspecified dimensions for a view.I've tried the solution above, but queryRenderedFeatures with point does not find any features, RectF variant works, but if I create rect from the size of the view it will catch the other features as well, should i then look for the closest one or do you have a better advice? Also if there any way i could trigger a pressed state on a marker view?
The way forward for this issue is to implement proper hit testing, for Marker this will mean using the height and width of Icon as bounds. For MarkerViews we will rely on View#getHitRect().
There is just one problem to be fixed here, and that is the issue of overlapping markers. I'm going to implement selecting a marker based on the overlap is has on the touch area.
update: this was fixed with intersecting the bounds with touch area and checking for the largest overlap of all the markers in the near area.
Activity
tobrun commentedon Mar 14, 2017
MarkerView clicks are now handled back on the View object since #8272. Relying on the platform implementation will provide the UX users are expecting. What remains for this ticket to close is optimizing the touch target for gl-based markers.
mariusboepple commentedon Mar 28, 2017
What is the status on this? Still having the issue with anchoring with
5.0.1(#7307).tobrun commentedon Mar 28, 2017
@mariusboepple anchoring is fixed with #8519 and is testable with the SNAPSHOT version.
mariusboepple commentedon Mar 28, 2017
@tobrun Thanks, I'll test soon!
tobrun commentedon Apr 19, 2017
MarkerView click behavior has been reverted with the 5.0.2 release in #8585. Issue is back in OP state.
pamartineza commentedon May 11, 2017
I have been discussing briefly this issue with your colleague @Guardiola31337
I'm using 5.0.2 release and still seeing inconsistent marker click behaviours:
If I declare a marker using "MarkerOptions", clicks are listened properly but icons appear anchored in the center.
val marker = mapboxMap.addMarker(MarkerOptions().position(latLng).icon(beachIcon))If I declare a marker using "MarkerViewOptions", clicks are listened but first one and icons are bottom center anchored.
val marker = mapboxMap.addMarker(MarkerViewOptions().position(latLng).icon(beachIcon))Is there any workaround right now to get clicks on markers properly while being able to have a bottom center anchored icon?
Thanks
nijs9 commentedon May 13, 2017
Same problem here. When clicking a markerview, first click infowindow is showed. Only at the second click, onMarkerClick is triggered. You need to click a markerview 2 times to trigger the onMarkerClick, and infowindow always appear.
MikeKasperlik commentedon May 17, 2017
Any news on this? I think having bottom centered annotations in a map AND allow the user to select them is not a too uncommon use-case. At least a workaround would be nice.
pamartineza commentedon May 18, 2017
@MikeKasperlik @nijs9 this has been solved in #8991 afaik the fix will be released next monday, but if you want you can already use the SNAPSHOT version:
MikeKasperlik commentedon May 18, 2017
Sadly still the same behaviour with the snapshot version (5.1.0). Only clicks on the lower half of my markerview is detected.
Larnoo commentedon May 18, 2017
I have a problem. My Marker view is very large, but the clickable area is small.
3 remaining items
galacticappster04 commentedon May 29, 2017
Any news on this one?
By the way, is this still related on marker clicks very large clickable area? This is really urgent in my case. I have my marker asset (which is a pointed marker) 2x height so it centers on its target. Unfortunately, this also enlarges its touch area such that tapping below the marker selects the marker itself, even though there is no marker there.
This really gets worse if you have a lot of markers in the screen. Selection jumps from marker to another. It is in fact annoying.
Is fix on the way?
tobrun commentedon May 29, 2017
Due to high request on this ticket, we are handling this as a high priority. Optimizing click events for all different size markers is a hard problem. To unblock you, I'm adding an example workaround. Though it needs to be fine tuned for your specific use-case + might need some additional InfoWindow management:
mare011 commentedon May 29, 2017
Hi I'm using MarkerViews, i have a layer of hexagons (like a bee hive) and markers in every hexagon, they are next to each others, but the click works just around the center of the view I've tried using both fixed and unspecified dimensions for a view.I've tried the solution above, but queryRenderedFeatures with point does not find any features, RectF variant works, but if I create rect from the size of the view it will catch the other features as well, should i then look for the closest one or do you have a better advice? Also if there any way i could trigger a pressed state on a marker view?
tobrun commentedon Jul 5, 2017
The way forward for this issue is to implement proper hit testing, for Marker this will mean using the height and width of Icon as bounds. For MarkerViews we will rely on
View#getHitRect().tobrun commentedon Jul 5, 2017
The
View#getHitRect()approach seems promising.One side note:
tobrun commentedon Jul 5, 2017
The hit testing for GL based markers works as well as above:
tobrun commentedon Jul 5, 2017
There is just one problem to be fixed here, and that is the issue of overlapping markers. I'm going to implement selecting a marker based on the overlap is has on the touch area.
update: this was fixed with intersecting the bounds with touch area and checking for the largest overlap of all the markers in the near area.
tobrun commentedon Jul 6, 2017
A MarkerView workaround that is backportable to older versions can be found here
basitsaleemmb commentedon Oct 1, 2018
how to increase marker click area