me-azharahmed / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

ItemizedIconOverlay never get called OnItemGestureListener #397

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi 
In the latest trunk 3.0.9  the OnItemGestureListener is no more called.

In 3.0.8 the following works (solution from issue 245):

import java.util.ArrayList;
import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.ResourceProxy;
import org.osmdroid.views.overlay.ItemizedIconOverlay;
import org.osmdroid.views.overlay.OverlayItem;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

public class osmItemizedOverlay  
{
    protected ItemizedIconOverlay<OverlayItem> mOverlay;
    protected Context mContext;
    protected Drawable mMarker;
    public boolean bVisible = true;

    public osmItemizedOverlay(Drawable marker, Context context) 
    {
        mContext = context;
        ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
        ResourceProxy resourceProxy = (ResourceProxy) new DefaultResourceProxyImpl(mContext);
        mMarker = marker;

        mOverlay = new ItemizedIconOverlay<OverlayItem>(
                items, mMarker, 
                new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() 
            {
            @Override public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
                return onSingleTapUpHelper(index, item);
            }

            @Override public boolean onItemLongPress(final int index, final OverlayItem item) {
                return true;
            }
            }, resourceProxy);

    }

    public boolean onSingleTapUpHelper(int i, OverlayItem item) {
        //Toast.makeText(mContext, "Item " + i + " has been tapped!", Toast.LENGTH_SHORT).show();
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        //dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();
        return true;

    }

    public void addItem(OverlayItem item){
        mOverlay.addItem(item);
    }

    public ItemizedIconOverlay<OverlayItem> getOverlay(){
        return mOverlay;
    }

}

Original issue reported on code.google.com by tfreudi...@googlemail.com on 24 Jan 2013 at 12:30

GoogleCodeExporter commented 8 years ago
This appears to be still working in the samples app - are you doing anything 
differently from SampleWithMinimapItemizedoverlayWithFocus for example?

Original comment by kurtzm...@gmail.com on 25 Jan 2013 at 7:56

GoogleCodeExporter commented 8 years ago
I think no. Also myLocation is always about 50 Pixel different to my real 
location. 
The coordinates are correct but the maptiles have this offset. I will try a new 
source download first. 

Original comment by tfreudi...@googlemail.com on 1 Feb 2013 at 10:01

GoogleCodeExporter commented 8 years ago
Ok I try the samples app now with the latest trunk of today and the fact is, 
also with my project, that I have to tap about 20 Pixels underneath 
marker_default.png than it works. I use a Samsung S3 I guess that has something 
to do with the size of "Overlayicon". In compare to 3.0.8 the iscon size is now 
fine on all kinds of different resolutions that I can test (S3,HTC Evo, HTC 
Desire, Sony V,SonyTablet, Galaxytablet).

Original comment by tfreudi...@googlemail.com on 6 Feb 2013 at 11:16

GoogleCodeExporter commented 8 years ago
I also experience this issue with the latest trunk.
My project hosts the map inside a fragment which is embedded in a sliding menu.

What I see:
- The mapped does not render correctly, it leaves a white strip at te bottom. I 
guess the calculation goes wrong somewhere because the strip varies in size 
depending on map movement.
- My Location and itemizedoverlays are not in the correct position. On the 
x-axis the position is correct, but on the y-axis it is off.

When I disable the use of the safecanvas and revert the changes in r1129 my 
problems are solved.

I had to revert r1129 because the view below the map always handles touch 
events.

Original comment by hans...@gmail.com on 13 Feb 2013 at 9:02

GoogleCodeExporter commented 8 years ago
I just tried the 3.0.9 release again. And have the same issues, but saw a tip 
to disable hardware acceleration.
Adding:
<application android:hardwareAccelerated="false" />
Helps me too. Now I can tap Items on the right position, not 20 Pixels below.

Original comment by tfreudi...@googlemail.com on 11 Apr 2013 at 10:45

GoogleCodeExporter commented 8 years ago
@hansvdg See issue 415 to fix the touch event issue.

Are there any more issues regarding this ticket?

Original comment by kurtzm...@gmail.com on 11 Apr 2013 at 3:06

GoogleCodeExporter commented 8 years ago
We have better hardware acceleration support in 3.0.10. This ticket can be 
closed.

Original comment by kurtzm...@gmail.com on 3 May 2013 at 12:47