我希望在 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!";
}
}
}
有没有办法做到这一点?