来自osmdroid的onsingletapup调用多个项目

时间:2013-07-15 15:21:10

标签: java android osmdroid itemizedoverlay

我已经与制造商创建了一个Osmdroid地图,但是有些标记非常接近,所以当我点击它时,会有很多“onSingleTapUp调用”,就像我在同一时间点击所有这些标记一样,我不明白为什么,即使我可以清楚地看到两个叠加项之间的空白,听众也会听两个水龙头。

        addOverlayItems();
        MyItemizedOverlay itemizedOverlay = new MyItemizedOverlay(context, items, gestureListener);
        map.getOverlays().add(itemizedOverlay);

        private void addOverlayItems(){
        for(int i = 0; i < sparetimes.size(); i++){
        SpareTimeObject sparetime = sparetimes.get(i);
        String title = sparetime.getLeisureTitle();
        String description = sparetime.getLeisureDescription();
        if(title == null){
            title = "Titre a definir";
        }
        if(description == null){
            description = "Description a definir";
        }
        if(sparetime.getLeisureLatitude() != null && sparetime.getLeisureLongitude() != null){
            double lat = Double.parseDouble(sparetime.getLeisureLatitude());
            double lon = Double.parseDouble(sparetime.getLeisureLongitude());
            GeoPoint geoPoint = new GeoPoint(lat, lon);
            MyOverlayItem item = new MyOverlayItem(title, description, geoPoint);

            items.add(item);
        }else{
            Log.i(TAG, "aucune localisation");
        }

    }
}
ItemizedIconOverlay.OnItemGestureListener<MyOverlayItem> gestureListener = new OnItemGestureListener<MyOverlayItem>() {

    @Override
    public boolean onItemLongPress(int arg0, MyOverlayItem arg1) {
        Log.i("onItemLongPress", ""+items.get(arg0).getTitle());
        return false;
    }

    @Override
    public boolean onItemSingleTapUp(int arg0, MyOverlayItem arg1) {
        Log.i("onItemSingleTapUp", ""+arg1.getTitle());
        Intent intent = new Intent(context, SpareTimeCardActivity.class);
        addToIntent(intent, sparetimes.get(arg0));
        context.startActivity(intent);
        return false;
    }

};

0 个答案:

没有答案