views:

663

answers:

1

I'm scaling markers on a MapView with the following code

OverlayItem oi = new OverlayItem(point,"Title", "Desc");
oi.setMarker(getCustomMarker(0.5f, 0.5f));
itemizedOverlay.addOverlay(oi);

and:

private BitmapDrawable getCustomMarker(float scaleWidth, float scaleHeight){
    int width = originalMarker.getWidth();
    int height = originalMarker.getHeight();

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    Bitmap bitmap = Bitmap.createBitmap(originalMarker, 0, 0, width, height, matrix, true);

    BitmapDrawable bm = new BitmapDrawable(bitmap);
    bm.setBounds(0,0,bitmap.getWidth(),bitmap.getHeight());

    return bm;
}

which works, but the shadow below the marker has wrong offset when scaled. Also; i override the public boolean onTap(int index) in ItemizedOverlay to detect taps on the markers, but it seems inaccurate. I can click some range outside the marker and still trigger onTap...

A: 

I use this to set the shadow

int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
drawable.setBounds(-w / 2, -h, w / 2, 0);
ArtWorkAD