9
BitmapDescriptor bmpD = BitmapDescriptorFactory.fromResource(R.raw.podval);

    Log.d("myLog", ":" + bmpD);

    GroundOverlayOptions newarkMap = new GroundOverlayOptions()
            .image(bmpD)
            .position(sydney, 8600f, 6500f);
    Log.d("myLog", ":" + newarkMap);
    GroundOverlay imageOverlay = mMap.addGroundOverlay(newarkMap);

Failed to decode image. The provided image must be a Bitmap. But in log I got :com.google.android.gms.maps.model.BitmapDescriptor@58e0ee6 :com.google.android.gms.maps.model.GroundOverlayOptions@1ea9c27

Also I converted jpg image to bmp, after failing to convert it here

Help please.

Asset Bekbossynov
  • 337
  • 3
  • 5
  • 16

2 Answers2

7

See https://stackoverflow.com/a/45564994/2914140 for vector drawables (SVG).

private BitmapDescriptor bitmapDescriptorFromVector(Context context, @DrawableRes int vectorResId) {
        Drawable vectorDrawable = ContextCompat.getDrawable(context, vectorResId);
        vectorDrawable.setBounds(0, 0, vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight());
        Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        vectorDrawable.draw(canvas);
        return BitmapDescriptorFactory.fromBitmap(bitmap);
}
CoolMind
  • 26,736
  • 15
  • 188
  • 224
4

Place your image in the drawable folder, not in the raw folder. Also make sure the resource is a valid image file.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59