Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

onMarkerClick not fired #12914

Closed
nijs9 opened this issue Sep 19, 2018 · 2 comments
Closed

onMarkerClick not fired #12914

nijs9 opened this issue Sep 19, 2018 · 2 comments
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity

Comments

@nijs9
Copy link

nijs9 commented Sep 19, 2018

A few months ago I reported an issue with onMarkerClick #11795. Since then, I downgraded to v5.2.0 to avoid this problem, and since a week, I upgraded again to v6.4.0 in hope that problem was solved this time.

A few users are reporting to me (f.e. users with a Galaxy A5 - Android 8.0) they can't click a marker, so on some devices, onMarkerClick is never fired (or in some cases the event is fired but on another marker than the one who has clicked). I can't reproduce this issue on my own devices.

This is a very annoying problem that has been dragging on for months. Is the only way to downgrade again tot v5.2.0?

In my case, I draw custom markers on map. Each time user drags the map, all markers are cleared and drawed again in the new bounding box.

When map is Idle I draw some markers:

    map.setOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
            @Override
            public void onCameraIdle() {

                if (!freeRouteOnMap) {

                    new showVisibleNodesOnMap().execute(getMapBounds());

                }

            }
        });

In showVisibleNodesOnMap I clear all current markers and draw new markers in the new bounding box:

clearAllNodesFromMap();
for (Node knooppunt : result) {

Marker marker = map.addMarker(new MarkerOptions()
                                    .position(new LatLng(knooppunt.getLocation().getLatitude(), knooppunt.getLocation().getLongitude()))
                                    .title(getString(R.string.routeplanner_10))
                                    .snippet(gson.toJson(knooppunt))
                                    .icon(icon)
}

And this is the markerclick event:

map.setOnMarkerClickListener(new MapboxMap.OnMarkerClickListener() {
                    @Override
                    public boolean onMarkerClick(@NonNull Marker marker) {

Gson gson = new Gson();
                            Node clickedNode = gson.fromJson(marker.getSnippet(), Node.class);

new showTrackBetweenPoints().execute();

}

Steps to reproduce

  1. Add some custom markers on map
  2. Clear all markers and add some new custom markers (a couple of times)
  3. Click marker an execute function (no infoWindow)

Expected behavior

Marker click event does the job.

Actual behavior

On some devices (f.e. Galaxy A5 - Android 8.0) click event is not triggered, or sometimes triggered on another marker than the one who has clicked.

Configuration

Android versions: 8.0
Device models: Galaxy A5
Mapbox SDK versions: 6.4.0

@nijs9 nijs9 changed the title onMarkerClick not fired on some devices onMarkerClick not fired on some devices: reason to downgrade? Sep 19, 2018
@tobrun tobrun added the Android Mapbox Maps SDK for Android label Sep 19, 2018
@tobrun tobrun changed the title onMarkerClick not fired on some devices: reason to downgrade? onMarkerClick not fired Sep 19, 2018
@tobrun
Copy link
Member

tobrun commented Oct 9, 2018

Would you be able to share the icons you are adding to your map or the dimensions of these images?
With #12482 we improved click handing of markers by taking in account marker detection when small icons are shown and it should resolve the issue you are having. Would love to get this resolved for you @nijs9! Looking forward to your response.

@stale stale bot added the archived Archived because of inactivity label Apr 7, 2019
@stale
Copy link

stale bot commented Apr 7, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Apr 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants