-1

我希望在 Customize BalloonPopup 上添加多个 onCLickListener 来处理不同的行为。

https://developer.nutiteq.com/guides/events

public class MyMapEventListener extends MapEventListener {
    private MapView mapView;
    private LocalVectorDataSource vectorDataSource;

    private BalloonPopup oldClickLabel;

    public MyMapEventListener(MapView mapView, LocalVectorDataSource vectorDataSource) {
        this.mapView = mapView;
        this.vectorDataSource = vectorDataSource;
    }



    @Override
    public void onMapClicked(MapClickInfo mapClickInfo) {
        Log.d(Const.LOG_TAG, "Map click!");

        // Remove old click label
        if (oldClickLabel != null) {
            vectorDataSource.remove(oldClickLabel);
            oldClickLabel = null;
        }

        BalloonPopupStyleBuilder balloonPopupStyleBuilder = new BalloonPopupStyleBuilder();
    balloonPopupStyleBuilder.setCornerRadius(20);
    balloonPopupStyleBuilder.setLeftMargins(new BalloonPopupMargins(6, 6, 6, 6));
    balloonPopupStyleBuilder.setLeftImage(BitmapUtils.createBitmapFromAndroidBitmap(infoImage));
    balloonPopupStyleBuilder.setRightImage(BitmapUtils.createBitmapFromAndroidBitmap(arrowImage));
    balloonPopupStyleBuilder.setRightMargins(new BalloonPopupMargins(2, 6, 12, 6));
    balloonPopupStyleBuilder.setPlacementPriority(1);
    BalloonPopup popup1 = new BalloonPopup(proj.fromWgs84(new MapPos(24.655662, 59.425521)),
                                           balloonPopupStyleBuilder.buildStyle(),
                                           "Popup with pos",
                                           "Images, round");
    popup1.setMetaDataElement("ClickText", "popupcaption nr 1");
    vectorDataSource1.add(popup1);

        // Check the type of the click
        String clickMsg = null;
        if (mapClickInfo.getClickType() == ClickType.CLICK_TYPE_SINGLE) {
            clickMsg = "Single map click!";
        } else if (mapClickInfo.getClickType() == ClickType.CLICK_TYPE_LONG) {
            clickMsg = "Long map click!";
        } else if (mapClickInfo.getClickType() == ClickType.CLICK_TYPE_DOUBLE) {
            clickMsg = "Double map click!";
        } else if (mapClickInfo.getClickType() == ClickType.CLICK_TYPE_DUAL) {
            clickMsg ="Dual map click!";
        }


    }
}

有没有办法做到这一点?

4

2 回答 2

0

恐怕使用当前的 Nutieq SDK API,您不能在一个 BalloonPopup 上拥有多个侦听器或按钮。解决方法是在地图上使用单独的 Android 视图而不是弹出窗口,例如谷歌地图应用程序最新版本所做的:他们不尝试显示复杂的数据,按钮作为地图弹出窗口,但为此使用单独的屏幕区域。

于 2015-10-07T13:17:04.970 回答
0

您是否尝试过实施GestureDetector.SimpleOnGestureListener课程?

于 2015-10-05T09:57:18.783 回答