androidmapboxmapbox-android

Map-box Android : Icon Overlapping and SymbolManager OnClickListener


I have got a strange issue when using the symbol manager. When I allow icons overlapping, the click listener of the symbol manager is triggered multiple times. This doesn't occur when I don't set Allow Icon Overlap to true. But I need to show all of the symbols on the map, and each one must open a dialog on click.

Is it a known issue or am I doing something wrong ?

Thanks for your help !


Solution

  • I too had the same problem. I used the symbolManager.addClickListener within the forloop which triggered the click multiple times.

    I resolved it by using the symbolManager.addClickListener inside onMapReady method.

    public void onMapReady(@NonNull MapboxMap mapboxMap) {
        map = mapboxMap;
        map.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
            @Override
            public void onStyleLoaded(@NonNull Style style) {
                symbolManager = new SymbolManager(mapView, mapboxMap, style);
    //          symbolManager.setIconAllowOverlap(true);
                symbolManager.addClickListener(new OnSymbolClickListener() {
                    @Override
                    public void onAnnotationClick(Symbol symbol) {
    
                    }
                });
            }
        });
    }