如何在android中在google地图上显示圆形图像

如何在android中在google地图上显示圆形图像,android,Android,以下是我在谷歌地图上绘制我的位置的代码: private Bitmap getCircleBitmap(Bitmap bitmap) { final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(output); final int

以下是我在谷歌地图上绘制我的位置的代码:

private Bitmap getCircleBitmap(Bitmap bitmap) {
     final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
      bitmap.getHeight(), Bitmap.Config.ARGB_8888);
     final Canvas canvas = new Canvas(output);

     final int color = Color.RED;
     final Paint paint = new Paint();
     final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
     final RectF rectF = new RectF(rect);

     paint.setAntiAlias(true);
     canvas.drawARGB(0, 0, 0, 0);
     paint.setColor(color);
     canvas.drawOval(rectF, paint);

     paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
     canvas.drawBitmap(bitmap, rect, rect, paint);

     bitmap.recycle();

     return output;
    }
目前,我打算在谷歌地图上显示一幅图像,而不是在marker上显示一幅矩形图像。我想把它显示成圆形。我已经写了一个显示圆形图像的方法,但是我不能在谷歌地图上调用它,在android中把图像显示成圆形

请告诉我我哪里做错了

public void drawMyLocation() {
        GPSTracker gps = new GPSTracker(getActivity());
        String imagePath = Environment.getExternalStorageDirectory().toString()
                + "/LociiImages/" + member_id + ".jpg";
        BitmapDescriptor icon = BitmapDescriptorFactory.fromPath(imagePath);

    //  getCircleBitmap(icon);

        if (gps.canGetLocation()) {
            double mylat = gps.getLatitude();
            double mylong = gps.getLongitude();
            LatLng myPoint = new LatLng(mylat, mylong);
            MarkerOptions marker = new MarkerOptions();
            marker.position(myPoint);
            marker.title("You");
            marker.snippet("You are here.");
            marker.icon(icon);
            map.addMarker(marker);


            // // Move the camera instantly to hamburg with a zoom of 15.
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(myPoint, 15));
            //
            // // Zoom in, animating the camera.
            map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
            //

        }
    }

替换此代码并享受

BitmapDescriptor icon=BitmapDescriptorFactory.fromBitmap(getCircleBitmap(yourBitmap))您的位图是什么@穆塔扎·侯赛因
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);



    BitmapDescriptor icon = BitmapDescriptorFactory
            .fromBitmap(getCircleBitmap(bitmap));