views:

61

answers:

1

I want to create a mapview marker with 4 elements: - picture (of user) - background - text (username) - Arrow to show an direction

OverlayItem.setMarker() accept only a drawable.

How can I create an drawable with 4 Items? Or can i add an View as marker to overlayItem?

any ideas?

A: 

I have found a solution. I create a BitmapDrawable

Here is the code

        Bitmap photo = ((BitmapDrawable)mActivity.getResources().getDrawable(R.drawable.user_picture_dummy)).getBitmap();

        Bitmap returnedBitmap = Bitmap.createBitmap(Global.dipToPx(40), Global.dipToPx(67), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(returnedBitmap);

        mBackground.setBounds(0, Global.dipToPx(10), canvas.getWidth(), canvas.getHeight());
        mBackground.draw(canvas);

        m.postScale((float)Global.dipToPx(30)/(float)photo.getWidth(), (float)Global.dipToPx(30)/(float)photo.getHeight());
        m.postTranslate(Global.dipToPx(5), Global.dipToPx(15));
        canvas.drawBitmap(photo, m, paint);
        m.reset();

        canvas.drawText(Global.DateToTimeString(adv.getStartDateMS()), Global.dipToPx(20), Global.dipToPx(10), paint);

        mat.postRotate((float)bearingTo(adv.getDepGeoPoint(), adv.getArrLocationObj().getGeoPoint()), mDirection.getWidth()/2, mDirection.getHeight()/2);
        mat.postTranslate(canvas.getWidth()-mDirection.getWidth(), canvas.getHeight()-mDirection.getHeight()-Global.dipToPx(12));
        canvas.drawBitmap(mDirection, mat, paint);
        mat.reset();

        BitmapDrawable drawable = new BitmapDrawable(returnedBitmap);
        boundCenter(drawable);

        OverlayItem item = new OverlayItem(adv.getDepGeoPoint(), adv.getOwnerObj().getUserName(), adv.getOwnerObj().getUserName());
        item.setMarker(drawable);
kodex83