首页 > 解决方案 > 如何处理同一位置标记上的点击事件

问题描述

我正在使用标记视图来显示标记。

我的代码:

View customView = LayoutInflater.from(activity).inflate(R.layout.dialog_obstacle_with_markers, null);
    customView.setLayoutParams(new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));

    ImageView iv_marker = customView.findViewById(R.id.iv_marker);
    iv_marker.setTag(reportItemArrayList.get(i).getReportId());
    ImageView iv_marker_white = customView.findViewById(R.id.iv_marker_white);
    FrameLayout fl_category = customView.findViewById(R.id.fl_category);
    ImageView iv_obstacle = customView.findViewById(R.id.iv_obstacle);
    TextView tv_obstacle = customView.findViewById(R.id.tv_obstacle);
    int[] rgbValue = Utils.getRGBFromHex(reportItemArrayList.get(i).getColor());
    iv_marker.setColorFilter(Color.rgb(rgbValue[0], rgbValue[1], rgbValue[2]));

    Glide.with(activity)
            .load(reportItemArrayList.get(i).getFilename())
            .apply(new RequestOptions()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .placeholder(R.mipmap.ic_obstacle_place_holder)
                    .error(R.mipmap.ic_obstacle_place_holder))
            .into(iv_obstacle);

    tv_obstacle.setText(reportItemArrayList.get(i).getCategoryName());

    MarkerView markerView = new MarkerView(new LatLng(Double.parseDouble(reportItemArrayList.get(i).getLat()), Double.parseDouble(reportItemArrayList.get(i).getLng())), customView);
    markerViewManager.addMarker(markerView);

在这里,我有多个相同的位置标记可用,并且由于相同的位置,我只能看到第一个位置标记和其他标记在第一个标记后面。

现在我想处理第一个标记后面的其他标记的点击事件。

目前,由于位置相同,我只获得了第一个位置标记点击。

但我希望所有点击事件都在第一个标记后面。

请帮我解决一下这个。

标签: androidmapbox-android

解决方案


你不能像这样处理相同位置标记的点击事件。标记应该有不同的位置来处理它们。


推荐阅读