我正在使用以下代码在MapView上缩放标记
OverlayItem oi = new OverlayItem(point,"Title", "Desc");
oi.setMarker(getCustomMarker(0.5f, 0.5f));
itemizedOverlay.addOverlay(oi);
和
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;
}
可以工作,但是缩放时标记下面的阴影有错误的偏移量。也;我覆盖ItemizedOverlay中的public boolean onTap(int index)
以检测标记上的点击,但它似乎不准确。我可以点击标记之外的某个范围并仍然触发onTap ...
答案 0 :(得分:1)
我用它来设置阴影
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
drawable.setBounds(-w / 2, -h, w / 2, 0);