Nutiteq MapView对长按不起作用

时间:2014-07-08 12:46:07

标签: android contextmenu android-mapview onlongclicklistener nutiteq

我已为MapListenerPolygons中的Markers实现了我自己的自定义Nutiteq,我可以显示Toasts并更改元素和其他内容的颜色但是如果我长时间点击标记或多边形,则听众不会做出反应。

我已经尝试过在我的customListener之外使用RegisterContextMenu,ContextMenuListener等,它是相同的,它不起作用。

如果我长按一个元素(标记/多边形),我的意图显示ContextMenu

代码如下

我已正确覆盖方法

public class MyFieldEventListener extends MapListener {
    private GeometryLayer layer;
    private Marker clickMarker;
    private MapView mapView;
    private Activity activity;


public MyFieldEventListener(Activity activity, MapView mapView, GeometryLayer layer, Marker clickMarker) {
    this.layer       = layer;
    this.clickMarker = clickMarker;
    this.mapView     = mapView;
    this.activity    = activity;

    // I have also tried with this line commented and it's the same
    mapView.setLongClickable(true); 

    // here I register my ContextMenu
    activity.registerForContextMenu(mapView); 

    // Here I define my ContextMenuListener and create a ContextMenu 
    mapView.setOnCreateContextMenuListener( new View.OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            Log.i("TAG", "WmsMapActivity:: setOnCreateContextMenuListener.onCreateContextMenu");
            menu.setHeaderTitle("Notes");

            menu.add(0, 1, 0, "Write Text Note");                   
        }
    } );        
}

@Override
public void onLabelClicked(VectorElement vectorElement, boolean longClick) {
    if (vectorElement.getLabel() != null) {
        if ( longClick )   
            mapView.showContextMenu();
        else { // Another Stuff... }
}

@Override
public void onVectorElementClicked(VectorElement vectorElement, double x, double y, boolean longClick) {
    if (vectorElement.getLabel() != null) {
        if (longclick)
            mapView.showContextMenu();
        else { // Another Stuff... }
    }       
}
...
}

我会感谢你的每一个评论,建议等

亲切的问候

1 个答案:

答案 0 :(得分:1)

也许您通过在代码中的某处调用mapView.getOptions()。setClickTypeDetection(false)来禁用单击检测?其他选项不应干扰点击检测。

如果不是这种情况,我建议您尝试Hellomap3D样本 - 它应该在点击显示的标记时显示吐司,并指示它是正常点击还是长'单击。它适用于我的手机。