jiaojian1 / osmdroid

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

tap on items does not work #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start OSMapView with ItemizedOverlay or OSMapView with 
ItemizedOverlayWithFocus
2. Tap on item
3. Toast does not appear.

What is the expected output? What do you see instead?
Expected output: Toast message about item.
Current state: Nothing happens

What version of the product are you using? On what operating system?
r119 (March 19 2010)

Please provide any additional information below.

OpenStreetMapViewItemizedOverlay.java contains error in onSingleTapUp. Take 
a look at: pj.toMapPixels(mItem.mGeoPoint, mCurScreenCoords).

    @Override
    public boolean onSingleTapUp(final MotionEvent event, final 
OpenStreetMapView mapView) {
        final OpenStreetMapViewProjection pj = 
mapView.getProjection();
        final int eventX = (int)event.getX();
        final int eventY = (int)event.getY();

        final int markerWidth = this.mMarker.getIntrinsicWidth();
        final int markerHeight = this.mMarker.getIntrinsicHeight();

        final Rect curMarkerBounds = new Rect();
        final Point mCurScreenCoords = new Point();

        for(int i = 0; i < this.mItemList.size(); i++){
            final T mItem = this.mItemList.get(i);
            pj.toMapPixels(mItem.mGeoPoint, mCurScreenCoords); 
// <<<< Error: Coordinates relative to map center in pixel get returned 
(very high values) 

            final int left = mCurScreenCoords.x - 
this.mMarkerHotSpot.x;
            final int right = left + markerWidth;
            final int top = mCurScreenCoords.y - 
this.mMarkerHotSpot.y;
            final int bottom = top + markerHeight;

            curMarkerBounds.set(left, top, right, bottom);
            if(curMarkerBounds.contains(eventX, eventY)) // 
<<<< Error: Cannot compare physical screen coordinates with relative map 
coordinates
                if(onTap(i))
                    return true;
        }
        return super.onSingleTapUp(event, mapView);
    }

Original issue reported on code.google.com by d.sc...@gmail.com on 24 Mar 2010 at 5:00

GoogleCodeExporter commented 9 years ago

Original comment by neilboyd on 25 Mar 2010 at 6:12