0

I've created an Osmdroid map with makers, but some markers are very close, so when i tap on it, there a lot of "onSingleTapUp called", it's like i'm clicking on all of them in the same time, and i don't see why, even when i can cleary see a blank between two overlay items the listener listen both taps.

        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;
    }

};
Tsunaze
  • 3,204
  • 7
  • 44
  • 81
  • One thought - is there any transparent space around your marker icons? So maybe the icons look like they aren't overlapping, but their transparent areas are overlapping. – kurtzmarc Jul 15 '13 at 16:28
  • I used the default marker, so i think there aren't any space around, i'm not sure. – Tsunaze Jul 16 '13 at 15:22
  • The default marker does not have space around it. So what is the main issue? Is the issue that overlapping items are getting "hit" and you want to know why, or are non-overlapping items getting "hit"? onItemSingleTapUp() will be called for each item at the location you tapped unless you return true for one of them. That is by design. – kurtzmarc Jul 16 '13 at 16:54
  • non overlapping items are getting hit. – Tsunaze Jul 17 '13 at 09:35

0 Answers0