Android:地图上的自定义标记

时间:2014-07-27 11:32:26

标签: android marker

我想将自定义标记添加到谷歌地图。我有一个标记的图片,我想添加

http://i.stack.imgur.com/AB5bb.png

我需要在此标记的中心粘贴/绘制圆圈图像

我该怎么办?

UPD:

//downloaded circle image
public Bitmap getCroppedBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    // canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    //Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
    //return _bmp;
    return output;
}  
//Draw Marker
public Bitmap pinMarker(Bitmap bitmap) {
    Bitmap.Config conf = Bitmap.Config.ARGB_8888;
    Resources res = context.getResources();
    Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.ic_pin_map);
    Canvas canvas1 = new Canvas(bmp.copy(conf, true));

    // paint defines the text color,
    // stroke width, size
    Paint color = new Paint();
    color.setTextSize(35);
    color.setColor(Color.BLACK);

    //modify canvas
    canvas1.drawBitmap(getCroppedBitmap(bitmap), 0,0, color);

    return bmp;
}

但它不起作用。我在地图上看到空标记

0 个答案:

没有答案